Skip to content

Commit

Permalink
feat/header json (#2)
Browse files Browse the repository at this point in the history
* feat: add content-type header as json on returns

* feat: just construct a data before return it

* docker: build with cache always

* json: removed the old setter
  • Loading branch information
Sanix-Darker authored Feb 19, 2022
1 parent c1008ab commit 0ccf73b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,34 +127,34 @@ app.post(`${BASE_ROUTE}/drop/:project/:database/:collection`, async (req, res) =
// A simple ping for checking if the service is up
// curl /api/v1/ping
app.get(`${BASE_ROUTE}/ping`, async (req, res) => {
res.json({
const data = {
"status": "success",
"server-ip": req.hostname,
"version": `GitRowsPack-Api-${version}`,
"message": `Welcome to the GitRowsPack shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://github.com/Sanix-Darker/gitrowspack-api`
});
"message": `Welcome to the GitRowsPack shell. For interactive help, type "help". For more comprehensive documentation, see https://github.com/Sanix-Darker/gitrowspack-api`
}
res.json(data);
});

// A simple endpoint to get the list of databases
// curl /api/v1/databases
app.get(`${BASE_ROUTE}/:project/databases`, async (req, res) => {
res.json({
const data = {
"project": req.params.project,
"databases": await gitrows.getDatabases(req.params.project)
});
}
res.json(data);
});

// A simple endpoint to get the list of databases
// curl /api/v1/collections
app.get(`${BASE_ROUTE}/:project/:database/collections`, async (req, res) => {
res.json({
const data = {
"project": req.params.project,
"database": req.params.database,
"collections": await gitrows.getCollections(req.params.project, req.params.database)
});
}
res.json(data);
});


Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"scripts": {
"dev": "nodemon index.js",
"start": "node index.js",
"docker-build": "docker build --no-cache -t sanixdarker/gitrowspack-api:latest -f Dockerfile .",
"docker-build-cache": "docker build -t sanixdarker/gitrowspack-api:latest -f Dockerfile .",
"docker-build": "docker build -t sanixdarker/gitrowspack-api:latest -f Dockerfile .",
"docker-run": "docker run --env-file .env -it --rm -p 3030:3030 sanixdarker/gitrowspack-api:latest"
},
"repository": {
Expand Down

0 comments on commit 0ccf73b

Please sign in to comment.