Last active
June 17, 2019 05:28
-
-
Save codeartistryio/f106e4048e0f8fe5b5dd01f13c486c8d to your computer and use it in GitHub Desktop.
JSON Server REST API Deployment
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
# Logs | |
logs | |
*.log | |
npm-debug.log* | |
# Runtime data | |
pids | |
*.pid | |
*.seed | |
*.pid.lock | |
# Directory for instrumented libs generated by jscoverage/JSCover | |
lib-cov | |
# Coverage directory used by tools like istanbul | |
coverage | |
# nyc test coverage | |
.nyc_output | |
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | |
.grunt | |
# node-waf configuration | |
.lock-wscript | |
# Compiled binary addons (http://nodejs.org/api/addons.html) | |
build/Release | |
# Dependency directories | |
node_modules | |
jspm_packages | |
# Optional npm cache directory | |
.npm | |
# Optional eslint cache | |
.eslintcache | |
# Optional REPL history | |
.node_repl_history | |
# Output of 'npm pack' | |
*.tgz | |
# Yarn Integrity file | |
.yarn-integrity | |
# dotenv environment variables file | |
.env | |
.vscode |
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
#!/usr/bin/env node | |
const jsonServer = require("json-server"); | |
const db = require("./db.json"); | |
const server = jsonServer.create(); | |
server.use(jsonServer.defaults()); | |
const router = jsonServer.router(db); | |
server.use(router); | |
server.listen(3777); | |
console.log(`API available on http://localhost:3777/users`); |
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
{ | |
"version": 2, | |
"builds": [{ "src": "index.js", "use": "@now/node-server" }], | |
"routes": [ | |
{ | |
"src": "/.*", | |
"dest": "/index.js" | |
} | |
] | |
} |
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
{ | |
"name": "rest-api", | |
"version": "1.0.0", | |
"repository": {}, | |
"license": "MIT", | |
"dependencies": { | |
"json-server": "^0.9.4" | |
}, | |
"scripts": { | |
"start": "json-server db.json" | |
}, | |
"bin": { | |
"index": "./index.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment