123456789101112131415161718192021222324252627282930313233343536373839404142 |
- const router = require('express').Router()
- import intro from '../intro'
- router.use('/v1/blocks', require('./blocks'))
- router.use('/v1/events', require('./events'))
- router.use('/v1/eras', require('./eras'))
- router.use('/v1/accounts', require('./accounts'))
- router.use('/v1/councils', require('./councils'))
- router.use('/v1/members', require('./members'))
- router.use('/v1/proposals', require('./proposals'))
- router.use('/v1/channels', require('./channels'))
- router.use('/v1/categories', require('./categories'))
- router.use('/v1/threads', require('./threads'))
- router.use('/v1/posts', require('./posts'))
- router.get('/v1', (req: any, res: any, next: any) => {
- try {
- res.send(`<pre>${intro}</pre>`)
- } catch (err) {
- console.log(err)
- next()
- }
- })
- router.get('/', (req: any, res: any, next: any) => {
- try {
- const versions = ['v1']
- res.send(`Available versions: <ul><li><a href='/api/v1'>/v1</a></li></ul>`)
- } catch (err) {
- console.log(err)
- next()
- }
- })
- router.use((req: any, res: any, next: any) => {
- const error = new Error(`Not Found: /api${req.url}`)
- //console.log(req)
- //error.status = 404
- next(error)
- })
- module.exports = router
|