From dee62128bdeaa409ce212461310c3f1bc77bd3ff Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Wed, 6 Sep 2023 19:59:44 -0400 Subject: [PATCH] setup prisma --- .env.template | 4 ++++ package.json | 1 + pnpm-lock.yaml | 17 +++++++++++++++++ prisma/schema.prisma | 11 +++++++++++ src/{http/index.ts => data/prisma.ts} | 0 src/http/fastify.ts | 5 +++++ src/index.ts | 6 ++++++ test/Crown.test.js | 25 ------------------------- 8 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 .env.template create mode 100644 prisma/schema.prisma rename src/{http/index.ts => data/prisma.ts} (100%) delete mode 100644 test/Crown.test.js diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..12ad753 --- /dev/null +++ b/.env.template @@ -0,0 +1,4 @@ +DATABASE_URL="sqlite:./db.sqlite" +PORT=8443 +ADMINPASS= +SALT= diff --git a/package.json b/package.json index 62b7ea0..e157c24 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "devDependencies": { "@types/node": "^20.5.9", + "prisma": "^5.2.0", "typescript": "^5.2.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 935c43d..15917a9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,6 +46,9 @@ devDependencies: '@types/node': specifier: ^20.5.9 version: 20.5.9 + prisma: + specifier: ^5.2.0 + version: 5.2.0 typescript: specifier: ^5.2.2 version: 5.2.2 @@ -74,6 +77,11 @@ packages: fast-json-stringify: 5.8.0 dev: false + /@prisma/engines@5.2.0: + resolution: {integrity: sha512-dT7FOLUCdZmq+AunLqB1Iz+ZH/IIS1Fz2THmKZQ6aFONrQD/BQ5ecJ7g2wGS2OgyUFf4OaLam6/bxmgdOBDqig==} + requiresBuild: true + dev: true + /@t3-oss/env-core@0.6.1(typescript@5.2.2)(zod@3.22.2): resolution: {integrity: sha512-KQD7qEDJtkWIWWmTVjNvk0wnHpkvAQ6CRbUxbWMFNG/fiosBQDQvtRpBNu6USxBscJCoC4z6y7P9MN52/mLOzw==} peerDependencies: @@ -466,6 +474,15 @@ packages: hasBin: true dev: false + /prisma@5.2.0: + resolution: {integrity: sha512-FfFlpjVCkZwrqxDnP4smlNYSH1so+CbfjgdpioFzGGqlQAEm6VHAYSzV7jJgC3ebtY9dNOhDMS2+4/1DDSM7bQ==} + engines: {node: '>=16.13'} + hasBin: true + requiresBuild: true + dependencies: + '@prisma/engines': 5.2.0 + dev: true + /process-warning@2.2.0: resolution: {integrity: sha512-/1WZ8+VQjR6avWOgHeEPd7SDQmFQ1B5mC1eRXsCm5TarlNmx/wCsa5GEaxGm05BORRtyG/Ex/3xq3TuRvq57qg==} dev: false diff --git a/prisma/schema.prisma b/prisma/schema.prisma new file mode 100644 index 0000000..d205f42 --- /dev/null +++ b/prisma/schema.prisma @@ -0,0 +1,11 @@ +// This is your Prisma schema file, +// learn more about it in the docs: https://pris.ly/d/prisma-schema + +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} diff --git a/src/http/index.ts b/src/data/prisma.ts similarity index 100% rename from src/http/index.ts rename to src/data/prisma.ts diff --git a/src/http/fastify.ts b/src/http/fastify.ts index e69de29..d634148 100644 --- a/src/http/fastify.ts +++ b/src/http/fastify.ts @@ -0,0 +1,5 @@ +import fastify from "fastify"; + +export const app = fastify({ + +}); diff --git a/src/index.ts b/src/index.ts index e69de29..4d52db6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -0,0 +1,6 @@ +import { app } from "http/fastify"; +import env from "util/env"; + +app.listen({ + port: env.PORT +}); diff --git a/test/Crown.test.js b/test/Crown.test.js deleted file mode 100644 index 8d61b4b..0000000 --- a/test/Crown.test.js +++ /dev/null @@ -1,25 +0,0 @@ -const Crown = require('../src/Crown'); - -describe('Crown', () => { - it('has a starting position of 50, 50', () => { - const crown = new Crown(); - - expect(crown.startPos.x).toBe(50); - expect(crown.startPos.y).toBe(50); - }); - - it('has a starting timestamp of Date.now()', () => { - const crown = new Crown(); - expect(crown.time).toBeLessThanOrEqual(Date.now()); - }); - - it('has a random end position', () => { - const crown = new Crown(); - - expect(crown.endPos.x).toBeLessThanOrEqual(100); - expect(crown.endPos.x).toBeGreaterThanOrEqual(0); - - expect(crown.endPos.y).toBeLessThanOrEqual(100); - expect(crown.endPos.y).toBeGreaterThanOrEqual(0); - }); -});