api.js 669 B

1234567891011121314151617181920212223242526
  1. import express from 'express'
  2. import bodyParser from 'body-parser'
  3. import bhttp from 'bhttp'
  4. import swisstennis from './routes/swisstennis'
  5. import { authenticate, verify } from './routes/authenticate'
  6. const port = process.env.PORT || 3002
  7. const app = express()
  8. app.use(bodyParser.urlencoded({ extended: false }))
  9. app.use(bodyParser.json())
  10. app.get('/', (req, res) => {
  11. res.send(`Express API at http://localhost:${port}/api`)
  12. })
  13. const apiRoutes = express.Router()
  14. apiRoutes.use('/swisstennis', swisstennis)
  15. app.use('/authenticate', authenticate)
  16. app.use('/api', verify)
  17. app.use('/api', apiRoutes)
  18. app.listen(port)
  19. console.log(`Server running on port ${port}.`)