ENDPOINT
ENDPOINT | METHOD | ACCESS |
---|---|---|
/register | POST | all |
/login | POST | all |
/articles | GET | all |
/articles | POST | all |
/articles/{articleId} | GET | all |
/articles/{articleId} | DELETE | author |
/articles/{articleId} | PUT | author |
/articles/{articleId}/comments | POST | all |
/articles/{articleId}/comments/{commentId} | DELETE | author & commentator |
/articles/{articleId}/comments/{commentId} | PUT | commentator |
HOW TO RUN THIS PROJECT
- clone this project
- move to project folder
cd /path/to/project
- run docker-compose
docker-compose -f docker-compose.yaml up
- set username name and password in mongodb
// run this if you want create user and this user can read write any where
db.createUser(
{
user: "root",
pwd: "root",
roles: ["userAdminAnyDatabase", "readWriteAnyDatabase"]
}
)
// run this if you want to create user for specific database
db.createUser({
user: "root",
pwd: "root",
roles: [
{
role: "readWrite",
db: "dbName"
}
]
})
- stop mongo container
docker-compose -f docker-compose.yaml stop
- re-create container
docker-compose -f docker-compose.yaml up
7create index on user collection
db.users.createIndex({username:1,email:1},{unique:true})
-
create schema validation, run schema on /app/schema/articles.js
-
run http server
go run main.go