@ladjs/api
Advanced tools
Comparing version 0.0.4 to 0.0.5
20
index.js
@@ -33,4 +33,3 @@ const http = require('http'); | ||
cabin: {}, | ||
protocol: process.env.API_PROTOCOL | 'http', | ||
port: process.env.API_PORT || 4000, | ||
protocol: process.env.API_PROTOCOL || 'http', | ||
ssl: { | ||
@@ -176,8 +175,18 @@ key: process.env.API_SSL_KEY_PATH | ||
// expose app and server | ||
this.app = app; | ||
this.server = server; | ||
// Expose app so we can test it without the server wrapper | ||
if (process.env.NODE_ENV === 'test') this.app = app; | ||
autoBind(this); | ||
} | ||
listen(fn) { | ||
listen(port, fn) { | ||
if (_.isFunction(port)) { | ||
fn = port; | ||
port = null; | ||
} | ||
const { logger } = this.config; | ||
@@ -192,6 +201,9 @@ if (!_.isFunction(fn)) | ||
this.server = this.server.listen(this.config.port, fn); | ||
this.server = this.server.listen(port, fn); | ||
return this.server; | ||
} | ||
close(fn) { | ||
this.server.close(fn); | ||
return this; | ||
} | ||
@@ -198,0 +210,0 @@ } |
{ | ||
"name": "@ladjs/api", | ||
"description": "API server for Lad", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
"ava": { | ||
"failFast": true, | ||
"verbose": true | ||
}, | ||
"bugs": { | ||
@@ -14,3 +18,3 @@ "url": "https://github.com/ladjs/api/issues", | ||
"dependencies": { | ||
"@ladjs/auth": "^0.0.3", | ||
"@ladjs/auth": "^0.0.4", | ||
"@ladjs/i18n": "^0.0.8", | ||
@@ -38,6 +42,2 @@ "@ladjs/store-ip-address": "^0.0.3", | ||
}, | ||
"ava": { | ||
"failFast": true, | ||
"verbose": true | ||
}, | ||
"devDependencies": { | ||
@@ -52,3 +52,5 @@ "auto-bind": "^1.1.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^5.0.0", | ||
"koa-router": "^7.3.0", | ||
"lint-staged": "^6.0.0", | ||
"mongoose": "^4.13.5", | ||
"nyc": "^11.3.0", | ||
@@ -58,2 +60,3 @@ "prettier": "^1.8.2", | ||
"remark-preset-github": "^0.0.7", | ||
"supertest": "^3.0.0", | ||
"xo": "^0.19.0" | ||
@@ -64,26 +67,27 @@ }, | ||
}, | ||
"files": ["index.js"], | ||
"homepage": "https://github.com/ladjs/api", | ||
"keywords": [ | ||
"api", | ||
"lad", | ||
"lass", | ||
"koa", | ||
"server", | ||
"web", | ||
"stripe", | ||
"error", | ||
"express", | ||
"fast", | ||
"handling", | ||
"json", | ||
"response", | ||
"express", | ||
"koa", | ||
"lad", | ||
"lass", | ||
"light", | ||
"lightweight", | ||
"limit", | ||
"limiting", | ||
"modern", | ||
"rate", | ||
"limit", | ||
"ratelimit", | ||
"ratelimiting", | ||
"limiting", | ||
"fast", | ||
"lightweight", | ||
"light", | ||
"simple" | ||
"response", | ||
"server", | ||
"simple", | ||
"stripe", | ||
"web" | ||
], | ||
@@ -90,0 +94,0 @@ "license": "MIT", |
@@ -38,28 +38,5 @@ # [**@ladjs/api**](https://github.com/ladjs/api) | ||
```js | ||
#!/usr/bin/env node | ||
const Server = require('@ladjs/api'); | ||
const Graceful = require('@ladjs/graceful'); | ||
See <https://github.com/ladjs/lad/blob/master/template/api.js> for the most up to date usage example. | ||
const routes = require('./routes'); | ||
const { i18n, logger } = require('./helpers'); | ||
const { Users } = require('./app/models'); | ||
const server = new Server({ | ||
Users, | ||
routes: routes.api, | ||
logger, | ||
i18n | ||
}); | ||
if (!module.parent) { | ||
server.listen(); | ||
const graceful = new Graceful({ server, logger }); | ||
graceful.listen(); | ||
} | ||
module.exports = server; | ||
``` | ||
## Contributors | ||
@@ -66,0 +43,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
174
11410
17
4
58
+ Added@ladjs/auth@0.0.4(transitive)
- Removed@ladjs/auth@0.0.3(transitive)
- Removedstrength@0.1.4(transitive)
Updated@ladjs/auth@^0.0.4