switched nodemon to pm2; replies with full note object, not just id
This commit is contained in:
+5
-2
@@ -15,7 +15,7 @@ services:
|
||||
build:
|
||||
context: ./node/
|
||||
dockerfile: Dockerfile
|
||||
restart: always
|
||||
#restart: always
|
||||
user: "node"
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
@@ -26,7 +26,10 @@ services:
|
||||
depends_on:
|
||||
- postgres
|
||||
working_dir: /home/node/app
|
||||
command: sh -c "yarn install && npx nodemon server.js"
|
||||
# for production (no file watching):
|
||||
# command: sh -c "yarn install && yarn pm2-runtime server.js"
|
||||
# for development (file watching/reloading):
|
||||
command: sh -c "yarn install && yarn pm2-dev server.js"
|
||||
postgres:
|
||||
image: "postgres:13.1-alpine"
|
||||
environment:
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"pg": "^8.5.1"
|
||||
"pg": "^8.5.1",
|
||||
"pm2": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -41,15 +41,15 @@ router.post('/load-notes', (req, res)=>{
|
||||
});
|
||||
|
||||
const search_stmt =
|
||||
"SELECT n.id FROM note AS n"
|
||||
+" WHERE n.text LIKE '%$1%'"
|
||||
"SELECT n.id, n.text, n.modified FROM note AS n"
|
||||
+" WHERE n.text LIKE '%' || $1 || '%'" // need to use string concat otherwise the `$1` is viewed as part of the string instead of a placeholder
|
||||
+" ORDER BY n.modified DESC";
|
||||
// {search_term, sorting, bin_id}
|
||||
router.post('/search', (req, res)=>{
|
||||
const search_term = req.body.search_term;
|
||||
db.query(search_stmt, [search_term])
|
||||
.then(result => {
|
||||
res.json({status:'ok', notes:result.rows.map(n=>n.id)});
|
||||
res.json({status:'ok', notes:result.rows});
|
||||
});
|
||||
// {status: 'ok', notes}
|
||||
});
|
||||
|
||||
+1223
-10
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user