A test-driven api with basic crud routes easily extended to new collections.
You will need postgresql installed on you machine. For mac users, go here.
Run these command to set up your local environment:
npm install
createdb basic_db
createdb basic_db_test
export BASIC_DB=postgres://localhost:5432/basic_db
export BASIC_DB_TEST=postgres://localhost:5432/basic_db_test
export TOKEN_SECRET=verysecret
Migrate databases (dev and testing):
sh resetDevDb.sh
sh resetTestDb.sh
Run the tests:
npm test
Run on localhost:3030:
gulp
response
{
data: [
{
id: 1
body: 'finish api markdown'
},
{
id: 2,
body: 'make coffee'
},
{
id: 3,
body: 'buy socks'
}
]
}
response
{
data: {
id: 1
body: 'finish api markdown'
},
}
post body
{
body: 'take a note'
}
response
{
data: {
id: 4,
body: 'take a note'
},
"message": "Created new row in Notes"
}
body
{
body: 'update a note'
}
response
{
data: {
id: 1,
body: 'update a note'
},
"message": "Edited id 1 in Notes"
}
response
{
"message": "Deleted id 1 in Notes"
}
body
{
user: {
username: String, // > 6 characters
password: String // > 6 characters
}
}
response
{
message: String,
token: JWT Token,
}
body
{
user: {
username: String,
password: String
}
}
response
{
message: String,
token: JWT Token,
}
header
Authorization: 'Bearer ' + token
response
{
message: String,
data: {
username: String,
_id: String
}
}