mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
38 lines
903 B
JavaScript
38 lines
903 B
JavaScript
import Koa from 'koa'
|
|
import bodyParser from 'koa-bodyparser'
|
|
import convert from 'koa-convert'
|
|
import logger from 'koa-logger'
|
|
import mongoose from 'mongoose'
|
|
import session from 'koa-generic-session'
|
|
import passport from 'koa-passport'
|
|
import mount from 'koa-mount'
|
|
import serve from 'koa-static'
|
|
|
|
import config from '../config'
|
|
import { errorMiddleware } from '../src/middleware'
|
|
|
|
const app = new Koa()
|
|
app.keys = [config.session]
|
|
|
|
mongoose.connect(config.database)
|
|
|
|
app.use(convert(logger()))
|
|
app.use(convert(bodyParser()))
|
|
app.use(convert(session()))
|
|
app.use(errorMiddleware())
|
|
|
|
app.use(convert(mount('/docs', serve(`${process.cwd()}/docs`))))
|
|
|
|
require('../config/passport')
|
|
app.use(passport.initialize())
|
|
app.use(passport.session())
|
|
|
|
const router = require('../src/controllers')
|
|
router(app)
|
|
|
|
app.listen(config.port, () => {
|
|
console.log(`Server started on ${config.port}`)
|
|
})
|
|
|
|
export default app
|