Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/william1nguyen/daily
Flashcard website for noting and learning
https://github.com/william1nguyen/daily
expressjs nodejs prisma
Last synced: 5 days ago
JSON representation
Flashcard website for noting and learning
- Host: GitHub
- URL: https://github.com/william1nguyen/daily
- Owner: william1nguyen
- Created: 2023-12-26T07:22:05.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2023-12-31T16:41:05.000Z (11 months ago)
- Last Synced: 2024-08-01T20:45:51.747Z (3 months ago)
- Topics: expressjs, nodejs, prisma
- Language: HTML
- Homepage:
- Size: 3.32 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DAILY BACKEND
- This backend serves as the backbone for the Daily App, offering essential APIs and hosting the frontend. To ensure smooth operation, follow the steps below.
## Requirements
- Nodejs >= 16.17.1## Setup virtual env (Optional)
### Setup `asdf`
- See how to install [asdf](https://asdf-vm.com/guide/getting-started.html)
- Install nodejs with required version
```
asdf install nodejs
```
- Apply nodejs
```
asdf local nodejs
```> [!WARNING]
> asdf will create `.tool-versions` file in order to determine nodejs version.## How to connect to local database
- Connect to `prisma`
```
$ npm install @prisma/client
$ npx prisma init
```- Install `sql` on terminal and create new user
```
$ CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'
$ GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
$ FLUSH PRIVILEGES;
```- CREATE DATABASE `daily`
```
$ CREATE DATABASE daily;
```- Change `DATABASE_URL` on .env to `mysql://daily:password@localhost:3306/daily`
- Create / Modify `models` on file `schema.prisma`
- Migrate```
$ npx prisma migrate dev --preview-feature
```- Run `prisma-cli`:
```
$ npx prisma studio
```## How to run
### Local setup
- **Install packages**
```
$ npm install
```- **Configure Environment**
Create a .env file from the provided .env.example and update the values accordingly.
```
$ cp .env.example .env
$ export $(grep -v '^#' .env | xargs)
```- **Initialize models database with Prisma**
```
$ npx primsa db push
```- **Run the Application**
```
$ npm start
```### Setup for deployment
- Just copy file `out/` build from **Frontend** to workspace.
- Run as local.