- Notifications
You must be signed in to change notification settings - Fork1
hongymagic/k2
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Koa 2 and GraphQL server thatjust works™. We've climbed the mountain ofboilerplate for you, so you don't have to.
- koa2 - write stuff in middleware
- babel - use latest ES6/7 features today. why wait?
- passport.js - easy authentication
- knex.js - documentation is better than sequelize
- GraphQL - it's the way to go
- Jest - don't let tests get in your way
- ramda - please don't use lodash or underscore
- prettier - don't worry about formatting…
- flowtype - get your types right
Make sure you have Docker installed as PostgreSQL is run on the dockercontainer.
git clone -o k2 -b master --single-branch https://github.com/hongymagic/k2.git example-apicd example-api # Change current directory to the newly created oneyarn install # Install required packages via yarncp .env.sample .env # Configuration on development mode is done via dotenvyarn migrate:latest # Run database migrationsyarn seed:run # Add some seed datayarn start:dev # Start the server in development mode
By default the API server starts on port 5000,http://localhost:5000.
┌── .env.sample # Sample .env file loaded into process.env├── docker-compose.yml # Auxiliary services such as postgresql via docker├── knexfile.js # Configuration for knex.js├── migrations/ # Database migrations. See below for more info├── seeds/ # Database seeds. See below for more info├── tests/ # Integration tests using supertest├── sqlite3/ # SQLite3 database location└── src/ ├── db.js # DB instance used by the app and/or models ├── models/ # ORM models written in ES6 classes ├── middleware/ # Custom middleware to be used by modules ├── modules/ # Route-Controller pair for koa2 │ ├── auth/ # Sample /authenticate module │ ├── graphql/ # GraphQL │ └── index.js # Don't touch this ├── passport.js # Passport.js configuration using passport-local ├── DataLoader.js # Data fetching layer for GraphQL ├── schema.js # GraphQL schema └── types/ # GraphQL types
K2 usesFacebook Jest so you can add adirectory named__tests__
at any level and start writing tests.
Root leveltests
directory is reserved for integration tests using supertest.Currently requires you to run the database server via docker-compose: see above.
yarn test # Run all tests including unit and integration testsyarn test:unit # Only run unit tests inside src/ directoryyarn test:integration # Only run integration tests inside tests/ directoryyarn test:coverage # Generate coverage report. Also travis default
This is a standard Node.js version 8.0+ application. You can deploy it toanywhere you like including, but not limited to:
- now.sh
- AWS Elastic Beanstalk
- Pretty much anything that runs docker or Node.js
Deploying to now is super simple if you're using SQLite3 (default). Just run:
now
Simply create a version of AWS EB with Node version 8.0.1 and deploy. Ipersonally have travis CI deploy it via aeb
script.
- TODO: Sample
.ebextensions/
- Database is already configured to prefer
RDS_{HOSTNAME,DB_NAME,USERNAME,PASSWORD}
connection information
About
Koa2 API template with passport, GraphQL, flowtype, knex and more.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.