forked from johndatserakis/koa-vue-notes-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 88d21fa
Showing
7 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"apps" : [ | ||
{ | ||
"name" : "koa-vue-notes-api", | ||
"script" : "index.js", | ||
"merge_logs" : true, | ||
"env": { | ||
"NODE_ENV": "production", | ||
"PORT": 4000 | ||
}, | ||
"instances": 2, | ||
"exec_mode" : "cluster_mode", | ||
"autorestart": true, | ||
"log_date_format": "YYYY-MM-DD HH:mm Z" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
const env = process.env.NODE_ENV || 'development'; | ||
const port = process.env.PORT || 4000; | ||
const src = env === 'production' ? './build/app' : './src/app'; | ||
|
||
require('babel-polyfill'); | ||
if (env === 'development') { | ||
require('babel-register'); | ||
} | ||
|
||
const app = require(src).default; | ||
app.listen(port); | ||
console.log('Server running at ' + port); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "koa-vue-notes-api", | ||
"version": "0.0.1", | ||
"description": "A SPA using Koa as the backend and Vue as the frontend.", | ||
"author": "John Datserakis", | ||
"private": true, | ||
"scripts": { | ||
"start": "node index.js", | ||
"watch": "nodemon --exec npm run start", | ||
"test": "npm run build; mocha --require 'babel-polyfill' --compilers js:babel-register", | ||
"build": "babel src -d build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/OrKoN/koa2-example-app.git" | ||
}, | ||
"keywords": [ | ||
"data", | ||
"node" | ||
], | ||
"license": "MIT", | ||
"homepage": "https://github.com/OrKoN/koa2-example-app#readme", | ||
"dependencies": { | ||
"babel-polyfill": "^6.5.0", | ||
"kcors": "^2.0.0", | ||
"koa": "^2.0.0-alpha.3", | ||
"koa-bodyparser": "^3.0.0", | ||
"koa-router": "^7.0.1", | ||
"promise-redis": "0.0.5", | ||
"redis": "^2.4.2" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.5.1", | ||
"babel-preset-es2015": "^6.5.0", | ||
"babel-preset-stage-3": "^6.5.0", | ||
"babel-register": "^6.9.0", | ||
"chai": "^3.5.0", | ||
"mocha": "^2.4.5", | ||
"nodemon": "^1.9.2", | ||
"supertest": "^1.2.0" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"es2015", | ||
"stage-3" | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#SPA using Koa as the backend and Vue as the frontend. | ||
|
||
Work In Progress. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Koa from 'koa'; | ||
import router from './router'; | ||
import bodyParser from 'koa-bodyparser'; | ||
import cors from 'kcors'; | ||
|
||
const app = new Koa() | ||
|
||
//For cors | ||
app.use(cors()) | ||
|
||
//For managing body | ||
app.use(bodyParser()) | ||
|
||
//For router | ||
app.use(router.routes()) | ||
app.use(router.allowedMethods()); | ||
|
||
//Birds-eye processing | ||
app.use(async (ctx, next) => { | ||
try { | ||
await next(); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}) | ||
|
||
export default app; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Router from 'koa-router' | ||
const router = new Router() | ||
|
||
router.get('/', async (ctx, next) => { | ||
ctx.body = 'Hello' | ||
}) | ||
|
||
export default router |