|
@@ -2,10 +2,11 @@ import * as account from './account/api'
|
|
import * as herd from './herd/api'
|
|
import * as herd from './herd/api'
|
|
import * as task from './task/api'
|
|
import * as task from './task/api'
|
|
import type { Context } from './types'
|
|
import type { Context } from './types'
|
|
-import type { ErrorRequestHandler } from 'express'
|
|
|
|
import cors from 'cors'
|
|
import cors from 'cors'
|
|
import express from 'express'
|
|
import express from 'express'
|
|
import { http } from '@edge/misc-utils'
|
|
import { http } from '@edge/misc-utils'
|
|
|
|
+import { version } from '../package.json'
|
|
|
|
+import type { ErrorRequestHandler, RequestHandler } from 'express'
|
|
|
|
|
|
/** Create an Express application. */
|
|
/** Create an Express application. */
|
|
function createExpress(ctx: Context) {
|
|
function createExpress(ctx: Context) {
|
|
@@ -17,6 +18,9 @@ function createExpress(ctx: Context) {
|
|
|
|
|
|
const prefix = ctx.config.api.prefix
|
|
const prefix = ctx.config.api.prefix
|
|
|
|
|
|
|
|
+ // Misc APIs
|
|
|
|
+ app.get(prefix, index)
|
|
|
|
+
|
|
// Account APIs
|
|
// Account APIs
|
|
app.post(`${prefix}/account`, account.createAccount(ctx))
|
|
app.post(`${prefix}/account`, account.createAccount(ctx))
|
|
app.get(`${prefix}/account/:id?`, account.getAccount())
|
|
app.get(`${prefix}/account/:id?`, account.getAccount())
|
|
@@ -63,4 +67,12 @@ function createExpress(ctx: Context) {
|
|
return app
|
|
return app
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const index: RequestHandler = (req, res, next) => {
|
|
|
|
+ res.send({
|
|
|
|
+ product: 'Herda Server',
|
|
|
|
+ version,
|
|
|
|
+ })
|
|
|
|
+ next()
|
|
|
|
+}
|
|
|
|
+
|
|
export default createExpress
|
|
export default createExpress
|