12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const router = require('express').Router()
- import intro from './intro'
- router.use('/v1/status', require('./status'))
- 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
|