Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
backend/index.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (24 sloc)
713 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Koa = require('koa'); | |
const Router = require('koa-router'); | |
const cors = require('@koa/cors'); | |
const app = new Koa(); | |
const router = new Router(); | |
//this lets the API make cross origin requests | |
const corsOptions = { | |
origin: 'https://open-saddle-3000.codio-box.uk', | |
} | |
router.get('/api', welcomeAPI); | |
function welcomeAPI(ctx) { | |
ctx.body = { | |
message: 'This is the root of the API' | |
} | |
} | |
const articles = require('./routes/articles.js'); | |
//const special = require('./routes/special.js'); | |
app.use(router.routes()); | |
//app.use(special.routes()); | |
app.use(articles.routes()); | |
app.use(cors(corsOptions)); | |
// run the app on port 3000 | |
//let port = process.env.PORT || 3000; | |
app.listen(3000); |