Last active
June 4, 2019 13:43
-
-
Save cyclecycle/19c98ca8b757fce3908c952ccb2c1e5c to your computer and use it in GitHub Desktop.
Modified version of skeleton.js generated by sqlite-to-rest that supports cross-origin requests
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
'use strict'; | |
//---------// | |
// Imports // | |
//---------// | |
const Koa = require('koa') | |
, sqliteToRest = require('sqlite-to-rest') | |
, cors = require('@koa/cors'); | |
//------// | |
// Init // | |
//------// | |
const dbPath = 'databases/test.db' | |
, getSqliteRouter = sqliteToRest.getSqliteRouter | |
, PORT = 8085; | |
//------// | |
// Main // | |
//------// | |
const app = new Koa(); | |
getSqliteRouter({ dbPath }) | |
.then(router => { | |
app.use(router.routes()) | |
.use(router.allowedMethods()) | |
.use(cors({origin: '*'})) | |
.listen(PORT); | |
console.log(`Listening on port: ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment