Skip to content

Commit

Permalink
feat: change to yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
bernarduswillson committed Oct 30, 2023
1 parent 0be43a7 commit a76e87e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "express-prisma",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "index.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "ts-node ./src/index.js",
"start": "ts-node ./src/index.ts",
"build": "tsc"
},
"keywords": [],
Expand All @@ -14,6 +14,7 @@
"dependencies": {
"@prisma/client": "^5.5.2",
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"googleapis": "^126.0.1",
Expand Down
1 change: 1 addition & 0 deletions prisma/migrations/db/tocorest.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ CREATE TABLE "users" (

-- CreateIndex
CREATE UNIQUE INDEX "email" ON "users"("email");
CREATE UNIQUE INDEX "name" ON "users"("name");
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ datasource db {

model users {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
name String @unique(map: "name") @db.VarChar(255)
email String @unique(map: "email") @db.VarChar(255)
address String? @db.VarChar(255)
password String? @db.VarChar(255)
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcrypt';
import jwt, { JwtPayload } from 'jsonwebtoken';

const cors = require('cors');
const app = express();
app.use(cors());
const PORT = 5000;
const prisma = new PrismaClient();

Expand Down Expand Up @@ -68,11 +70,11 @@ app.use('/register', async (req, res) => {

// LOGIN
app.use('/login', async (req, res) => {
const {email, password} = req.body;
const {name, password} = req.body;

const user = await prisma.users.findUnique({
const user = await prisma.users.findFirst({
where: {
email: email
name: name,
}
})

Expand Down

0 comments on commit a76e87e

Please sign in to comment.