Code Monkey home page Code Monkey logo

koa-restful-boilerplate's Introduction

Koa 2 Restful Boilerplate

Description

Koa 2 RESTful API using :

  • Koa 2
  • Mongodb + Mongoose
  • Babel
  • Asynchronous Functions (Async/Await)

Running

Install dependencies

npm install

Start a Local Server

npm start

Run Test

npm test

Building and Running Production Server

npm run prod

Note : Please make sure your MongoDB is running before using npm start or npm run prod

License

MIT © Thomas Blanc-Hector

koa-restful-boilerplate's People

Contributors

jsnomad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

koa-restful-boilerplate's Issues

Unexpected token function

Hello, I cloned repository, installed dependencies, but, when running npm start, i get:

\node_modules\koa-bodyparser\index.js:72
  return async function bodyParser(ctx, next) {
               ^^^^^^^^
SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Module._extensions..js (module.js:579:10)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\gianluca.paris\Desktop\a\together\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
[nodemon] app crashed - waiting for file changes before starting...

I can't use router

I use Koa@2 and koa-router 7.0.1
Here is code.

import Koa from 'koa';
import mongoose from 'mongoose';
import logger from 'koa-logger';
import parser from 'koa-bodyparser';
import router from 'koa-router';

const api = router();
const app = new Koa();

app.use(logger()) // Logs information.
  .use(parser()) // Parses json body requests.
  .use(async (ctx, next) => ctx.body = 'Hello World')
  .use(router.routes())
  .use(router.allowedMethods());

api.get('/', async (ctx, next) =>
  ctx.body = 'Get api'
);

app.listen(3000, () => console.log('Listening on port 3000.'));

export default app;

And when I run npm start
It show error to me.
I can't understand what's wrong at my code.

2016-10-08 15 56 59

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.