Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dacurse/note-app
An API for a note taking app.
https://github.com/dacurse/note-app
crud express javascript nodejs prisma
Last synced: 29 days ago
JSON representation
An API for a note taking app.
- Host: GitHub
- URL: https://github.com/dacurse/note-app
- Owner: DaCurse
- License: gpl-3.0
- Created: 2021-12-04T15:14:57.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-18T22:48:17.000Z (about 3 years ago)
- Last Synced: 2024-11-07T20:40:59.864Z (3 months ago)
- Topics: crud, express, javascript, nodejs, prisma
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# note-app
An API for a note taking app.
I made this little project because I find writing pure express apps, without any sophisticated frameworks (Like [Nest.js](https://nestjs.com/)) fun, and also because I wanted to create a project structure I am happy with, and I think I got close here.
This project structure seperates responsibilities to different components (Routes, services, etc.), and has nifty utilities like clean declarative validation which automatically throws descriptive errors:
```js
router.get('/', validate(getNotesSchema, 'query'), async (req, res) =>
res.json(await getNotes(req.query.limit))
);
```If `req.query` doesn't match the schema, I get an error:
```json
{
"status": 400,
"message": "\"id\" must be a number"
}
```## Running the project
Rename [.env.example](./.env.example) to `.env` and fill in the required information.
Install dependencies using your preferred package manager (I use [pnpm](https://pnpm.io/)):
```sh
pnpm i
```Run in watch mode (for development):
```sh
pnpm start:dev
```Or for production:
```sh
DEBUG=note-app:* pnpm start
```_The `DEBUG` environment variable doesn't work with `.env` files._
### With Docker
Build an image from the repo:
```sh
sudo docker image build https://github.com/DaCurse/note-app.git -t note-app:latest
```And create a container:
```sh
docker run -d \
-it \
--restart unless-stopped \
--name note-app -p 80:80 \
-e "DATABASE_URL=" \
--mount type=bind,source=/var/lib/note-app/data,target=/var/lib/postgresql/data/pgdata \
note-app:latest
```### With docker-compose
With `docker-compose`, a `postgres` server is started alongisde the app.
Clone the repo:
```sh
git clone https://github.com/DaCurse/note-app.git
cd note-app
```Start the app:
```sh
sudo docker-compose up -d
```## License
See [LICENSE](./LICENSE).