mirror of
https://github.com/Floriansylvain/CineAllo.git
synced 2026-08-19 11:43:24 +02:00
🎉 - First commit!
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
# Keep environment variables out of version control
|
||||||
|
.env
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
mysql-data
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
FROM node:16.18.1-bullseye-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json ./
|
||||||
|
COPY package-lock.json ./
|
||||||
|
COPY .env ./
|
||||||
|
COPY app.js ./
|
||||||
|
ADD routes ./routes/
|
||||||
|
ADD prisma ./prisma/
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start"]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import logger from 'morgan'
|
||||||
|
import * as dotenv from 'dotenv'
|
||||||
|
import { indexRouter } from './routes/index.js'
|
||||||
|
import { usersRouter } from './routes/users.js'
|
||||||
|
|
||||||
|
dotenv.config()
|
||||||
|
const app = express()
|
||||||
|
const port = process.env.CINEALLO_PORT
|
||||||
|
|
||||||
|
app.use(logger('dev'))
|
||||||
|
app.use(express.json())
|
||||||
|
app.use(express.urlencoded({ extended: false }))
|
||||||
|
|
||||||
|
app.use('/', indexRouter)
|
||||||
|
app.use('/users', usersRouter)
|
||||||
|
|
||||||
|
app.listen(port, () => console.log(`Listening on port ${port}`))
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
build: .
|
||||||
|
image: cineallo-backend
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
networks:
|
||||||
|
- back-net
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
db:
|
||||||
|
image: mysql:8.0.31
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
networks:
|
||||||
|
- back-net
|
||||||
|
environment:
|
||||||
|
- "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}"
|
||||||
|
- "MYSQL_DATABASE=cineallo"
|
||||||
|
volumes:
|
||||||
|
- ./mysql-data:/var/lib/mysql
|
||||||
|
|
||||||
|
networks:
|
||||||
|
back-net:
|
||||||
Generated
+1139
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "expresstemplate",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node app.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@prisma/client": "^4.6.0",
|
||||||
|
"debug": "~2.6.9",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"express": "~4.16.1",
|
||||||
|
"http-errors": "~2.0.0",
|
||||||
|
"morgan": "~1.9.1",
|
||||||
|
"prisma": "^4.6.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE `Article` (
|
||||||
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||||
|
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "mysql"
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// 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 = "mysql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Article {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
title String
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import express from 'express'
|
||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
export const indexRouter = express.Router()
|
||||||
|
|
||||||
|
indexRouter.get('/', async (req, res, next) => {
|
||||||
|
res.send({message:"voila ton index"})
|
||||||
|
})
|
||||||
|
|
||||||
|
indexRouter.get('/articles', async (req, res, next) => {
|
||||||
|
const articles = await prisma.article.findMany({})
|
||||||
|
res.send({
|
||||||
|
message:"voila tes articles",
|
||||||
|
articles
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import express from 'express'
|
||||||
|
|
||||||
|
export const usersRouter = express.Router()
|
||||||
|
|
||||||
|
usersRouter.get('/', function(req, res, next) {
|
||||||
|
res.send({message:"voila tes users"})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user