locosoft1986 / next-reservation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a Next.js project bootstrapped with create-next-app.

Mongo DB setup

According to the document of mongo db connection module of Prisma, the mongo db should be in a replica set.

Suppose your local db file is stored in ~/projects/db/mongodb

By using docker as a faster database setup, run the following command:

docker run --rm -d -p 27017:27017 -h $(hostname) --name mongo -v ~/projects/db/mongodb:/data/db mongo:latest --replSet=dbrs && sleep 5 && docker exec mongo mongosh --quiet --eval "rs.initiate();"

Remember to replace the host directory for the "~/projects/db/mongodb" for your own settings.

Reference article for the single replica mongoDB local development environment.

https://nmihaylov.medium.com/setting-up-a-local-mongodb-replica-set-with-a-single-node-e04fb3213123

Getting Started

  1. First, copy the local env-example file in the project root and rename it to ".env".
DATABASE_URL=mongodb://127.0.0.1:27017/restaurant?replicaSet=dbrs
NEXTAUTH_SECRET=

GITHUB_ID=
GITHUB_SECRET=
LOG_FILE=app.log

If you are in local development environment, the DATABASE_URL should be unchanged.

Fill in the NEXTAUTH_SECRET as randomly as you want.

  1. run the following commands to initialize and push the Prisma schema into mongodb
yarn

npx prisma db push 

npx prisma generate 
  1. run the development server:
yarn dev

Open http://localhost:3000 with your browser to see the result.

  1. You should register your first account. For the demo purpose, the first account that is registered will automatically be an admin account.
  2. Admin can create tables first, then users can create reservations based on the date selection on the top.

About


Languages

Language:TypeScript 99.6%Language:JavaScript 0.3%Language:CSS 0.2%