[javascript] refactoring
This commit is contained in:
parent
01e3f05ea0
commit
0377c99a54
3 changed files with 6 additions and 4 deletions
|
@ -1,9 +1,11 @@
|
|||
import * as api from './api.js';
|
||||
import * as db from '../database/systems.js';
|
||||
import * as utils from './utils.js';
|
||||
|
||||
|
||||
// Retrieves a shipyard's information for ctx.symbol
|
||||
export async function shipyard(ctx) {
|
||||
const systemSymbol = ctx.symbol.match(/([^-]+-[^-]+)/)[1]; // TODO generalise this extraction
|
||||
const systemSymbol = utils.systemFromWaypoint(ctx.symbol);
|
||||
console.log(systemSymbol);
|
||||
return await api.send({endpoint: `/systems/${systemSymbol}/waypoints/${ctx.symbol}/shipyard`});
|
||||
}
|
||||
|
|
3
nodejs/lib/utils.js
Normal file
3
nodejs/lib/utils.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function systemFromWaypoint(waypoint) {
|
||||
return waypoint.split('-').slice(0,2).join('-');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue