Skip to content

Instantly share code, notes, and snippets.

@codeartistryio
Last active June 17, 2019 05:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeartistryio/f106e4048e0f8fe5b5dd01f13c486c8d to your computer and use it in GitHub Desktop.
Save codeartistryio/f106e4048e0f8fe5b5dd01f13c486c8d to your computer and use it in GitHub Desktop.
JSON Server REST API Deployment
# 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
#!/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`);
{
"version": 2,
"builds": [{ "src": "index.js", "use": "@now/node-server" }],
"routes": [
{
"src": "/.*",
"dest": "/index.js"
}
]
}
{
"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