- Lets an authenticated user insert and delete server configurations
- Allows for the listing of server configurations with more than 100,000 entries
- Allows for sorting the listing by name, hostname, port, or username
Note: I will be providing schemas, or ODM (Object Data Mapping), shortly... via Mongoose.
- Clone the repository
- Duplicate "config/database_sample.js" and rename it to "database.js"
- You can create an account on Modulus (https://modulus.io/), with up to 64MB of free storage
- Or, of course, you can run your own MongoDB instance
- Duplicate "config/secret_sample.js" and rename it to "secret.js"
- Modify the default "secret" to something different
#!bash
npm install
#!bash
node server.js
or using forever
#!bash
forever start server.js
A screenshot of the web interface for performing tests, kinda like a watered-down Postman.
{
"email":"youremail@gmail.com",
"password":"yourpassword"
}
curl -i -X POST -H "Content-Type: application/json" -d '{"email":"youremail@gmail.com", "password":"yourpassword"}' http://localhost:3000/login
curl -i -X POST -H "Content-Type: application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" http://localhost:3000/logout
sort field / order / skip / max
curl -i -X GET -H "content-type:application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" http://localhost:3000/api/configurations/port/asc/0/50
curl -i -X GET -H "content-type:application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" http://localhost:3000/api/configuration/541a405494faef4be2adf4d1
{
"name":"host221122",
"hostname":"nodejs.developer.io",
"port":"2112",
"username":"nodejsdev@developer.io"
}
curl -i -X POST -H "content-type:application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" -d '{"name":"host221122" , "hostname":"nodejs.developer.io" , "port":"2112", "username":"nodejsdev@developer.io"}' http://localhost:3000/api/configuration/
{
"name": "host104",
"hostname": "zzzzzz.georgianna.biz",
"port": 2179,
"username": "zzzzzz@karelle.org"
}
curl -i -X PUT -H "content-type:application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" -d '{ "name": "host104", "hostname": "zzzzzz.georgianna.biz", "port": 2179, "username": "zzzzzz@karelle.org" }' http://localhost:3000/api/configuration/541a405494faef4be2adf4d1
curl -i -X DELETE -H "content-type:application/json" -H "x-access-token:YOUR_AUTH_TOKEN" -H "x-key:youremail@gmail.com" http://localhost:3000/api/configuration/541a405494faef4be2adf4d1
- Goran Halusa
- gor@webcraftr.com
- Issue Tracker
- https://github.com/ghalusa/nodejs-rest-api/issues