Skip to content

Commit 4a950b1

Browse files
author
Franciszek Stodulski
committed
build: created prisma starter
0 parents  commit 4a950b1

19 files changed

+3787
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
generated
2+
node_modules/
3+
schema-compiled.graphql

GRAPHQL_index.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as bodyParser from 'body-parser-graphql';
2+
import { GraphQLServer } from 'graphql-yoga';
3+
import { prisma } from './generated/prisma-client';
4+
import { resolvers } from './src/graphql/resolvers';
5+
6+
const server = new GraphQLServer({
7+
context: (req, res) => ({
8+
...req,
9+
...res,
10+
prisma,
11+
}),
12+
resolvers,
13+
typeDefs: './schema-compiled.graphql',
14+
});
15+
16+
server.use(bodyParser.graphql());
17+
server.start(() => console.log('Server is running on http://localhost:4000'));

REST_index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as express from 'express';
2+
3+
import { AddNewUser, AllUsers } from './src/REST/controllers/User';
4+
5+
const app = express();
6+
7+
const PORT = 3200;
8+
9+
app.get('/', (req, res) => {
10+
res.send({
11+
message: 'ok',
12+
});
13+
});
14+
15+
app.get('/addUser', AddNewUser);
16+
17+
app.get('/allUsers', AllUsers);
18+
19+
app.listen(PORT, () => `Server is listening on ${PORT}`);

commintlint.conf.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional']
3+
}

datamodel.prisma

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type User {
2+
id: ID! @id
3+
email: String @unique
4+
name: String!
5+
posts: [Post!]!
6+
}
7+
8+
type Post {
9+
id: ID! @id
10+
title: String!
11+
published: Boolean! @default(value: false)
12+
author: User @relation(link: INLINE)
13+
}

docker-compose.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: "3"
2+
services:
3+
prisma:
4+
image: prismagraphql/prisma:1.34
5+
restart: always
6+
ports:
7+
- "4466:4466"
8+
environment:
9+
PRISMA_CONFIG: |
10+
port: 4466
11+
databases:
12+
default:
13+
connector: mysql
14+
host: mysql
15+
port: 3306
16+
user: root
17+
password: prisma
18+
mysql:
19+
image: mysql:5.7
20+
restart: always
21+
environment:
22+
MYSQL_ROOT_PASSWORD: prisma
23+
volumes:
24+
- mysql:/var/lib/mysql
25+
volumes:
26+
mysql: ~

gen-schema.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { importSchema } from 'graphql-import';
2+
3+
import { writeFileSync } from 'fs';
4+
5+
const newSchema = importSchema('./schema.graphql');
6+
7+
writeFileSync('./schema-compiled.graphql', newSchema);

0 commit comments

Comments
 (0)