feat(server): add field "identifier"

I'm going to replace the function of "main.js".
This commit is contained in:
pan93412 2022-01-26 14:20:54 +08:00
parent 5bf53028ef
commit 4e434a2691
No known key found for this signature in database
GPG Key ID: 42154B1B1CFE3377

View File

@ -22,6 +22,7 @@ const VERSION_CHECK_RESULT = {
/** /**
* @typedef {{ * @typedef {{
* identifier?: string,
* route: string, * route: string,
* module: any * module: any
* }} ModuleDefinition * }} ModuleDefinition
@ -70,10 +71,11 @@ async function getModulesDefinitions(modulePath, specificRoute) {
.reverse() .reverse()
.filter((file) => file.endsWith('.js')) .filter((file) => file.endsWith('.js'))
.map((file) => { .map((file) => {
const identifier = file.split('.').shift()
const route = parseRoute(file) const route = parseRoute(file)
const module = require(path.join(modulePath, file)) const module = require(path.join(modulePath, file))
return { route, module } return { identifier, route, module }
}) })
return modules return modules