https://github.com/iamgrid/nodejs-quick-rest-api
Meant to be ran on localhost (with "npm start"), you put the object you want to get back as JSON as a property of your app object in .\responseLibrary.js, you fetch from the endpoint like http://localhost:3001?app=yourFirstAppId&key=yourPropertyKey1 and hey presto, your very own REST server.
https://github.com/iamgrid/nodejs-quick-rest-api
express expressjs nodejs rest rest-api
Last synced: about 1 month ago
JSON representation
Meant to be ran on localhost (with "npm start"), you put the object you want to get back as JSON as a property of your app object in .\responseLibrary.js, you fetch from the endpoint like http://localhost:3001?app=yourFirstAppId&key=yourPropertyKey1 and hey presto, your very own REST server.
- Host: GitHub
- URL: https://github.com/iamgrid/nodejs-quick-rest-api
- Owner: iamgrid
- License: mit
- Created: 2023-01-18T19:23:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-21T16:29:30.000Z (over 3 years ago)
- Last Synced: 2025-09-04T12:56:35.785Z (9 months ago)
- Topics: express, expressjs, nodejs, rest, rest-api
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nodejs-quick-rest-api
## Introduction
Meant to be ran on localhost (with "npm start"), you put the object you want to get back as JSON as a property of your app object in .\responseLibrary.js, you fetch from the endpoint like http://localhost:3001?app=yourFirstAppId&key=yourPropertyKey1 and hey presto, your very own REST server.
## Installation
1. `git clone` the repo into a folder of your choice
2. `cd nodejs-quick-rest-api` (enter the folder the clone command created)
3. `npm install` to install this project's required packages defined in package.json (the packages are express and nodemon)
4. Create your responseLibrary.js file in the root folder. The contents should be something like:
```
const yourFirstAppId = {
"yourPropertyKey1": {
are: "you ok",
of: "course, never better"
},
"yourPropertyKey2": {
youForgot: "to work",
the: "thingamabob"
}
};
const yourSecondAppId = {
"yourPropertyKey3": {
niceDay: "for",
fishing: "ain't it"
}
};
module.exports = { yourFirstAppId, yourSecondAppId };
```
## Usage
1. `npm start`
2. Talk to the server while it is listening by fetching from the url `http://localhost:3001?app=yourFirstAppId&key=yourPropertyKey1`
Thanks to the nodemon package, as you save changes to your responseLibrary.js or index.js the server will automatically restart to reflect your updates.