add prettier
This commit is contained in:
parent
868b46317d
commit
63478aa887
22
api/package-lock.json
generated
22
api/package-lock.json
generated
@ -21,6 +21,7 @@
|
||||
"@types/express-session": "^1.17.5",
|
||||
"@types/ip": "^1.1.0",
|
||||
"@types/node": "^18.7.18",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
@ -1124,6 +1125,21 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@ -2508,6 +2524,12 @@
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true
|
||||
},
|
||||
"proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
|
@ -7,7 +7,8 @@
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "ts-node-dev --respawn --transpile-only ./src/app.ts",
|
||||
"start": "npm run build && node ./dist/app.js"
|
||||
"start": "npm run build && node ./dist/app.js",
|
||||
"prettier": "prettier -w ./src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/cors": "^2.8.12",
|
||||
@ -15,6 +16,7 @@
|
||||
"@types/express-session": "^1.17.5",
|
||||
"@types/ip": "^1.1.0",
|
||||
"@types/node": "^18.7.18",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node-dev": "^2.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
|
@ -1,16 +1,18 @@
|
||||
import Server, { Services } from './framework/express/server';
|
||||
import Mongo from './framework/mongo/mongo';
|
||||
import ip from "ip";
|
||||
import ip from 'ip';
|
||||
|
||||
const PORT = 8000;
|
||||
const MONGOURI = "mongodb://localhost:27017";
|
||||
const MONGOURI = 'mongodb://localhost:27017';
|
||||
|
||||
const mongo = new Mongo(MONGOURI);
|
||||
|
||||
const services: Services = {
|
||||
db: mongo.getDb()
|
||||
}
|
||||
db: mongo.getDb(),
|
||||
};
|
||||
|
||||
const server = new Server(services);
|
||||
|
||||
server.start(PORT, () => console.log(`Running on http://${ip.address()}:${PORT}`));
|
||||
server.start(PORT, () =>
|
||||
console.log(`Running on http://${ip.address()}:${PORT}`),
|
||||
);
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { randomUUID } from "crypto";
|
||||
import { RequestHandler } from 'express';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
export function BeforeEach(): RequestHandler {
|
||||
return (req, res, next) => {
|
||||
req.headers["request-id"] = randomUUID();
|
||||
req.headers['request-id'] = randomUUID();
|
||||
next();
|
||||
}
|
||||
};
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
import { Router } from "express";
|
||||
import { Services } from "./server";
|
||||
import * as user from "./user";
|
||||
import { Router } from 'express';
|
||||
import { Services } from './server';
|
||||
import * as user from './user';
|
||||
|
||||
export function getRoutes(services: Services) {
|
||||
const router = Router();
|
||||
|
||||
router.use("/user", user.getRoutes(services));
|
||||
router.use('/user', user.getRoutes(services));
|
||||
|
||||
return router;
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import express, { Express } from "express";
|
||||
import express, { Express } from 'express';
|
||||
import cors from 'cors';
|
||||
import * as router from './router';
|
||||
import { BeforeEach } from "./middleware";
|
||||
import { Db } from "mongodb";
|
||||
import { BeforeEach } from './middleware';
|
||||
import { Db } from 'mongodb';
|
||||
|
||||
export type Services = {
|
||||
db: Db;
|
||||
}
|
||||
};
|
||||
|
||||
class Server {
|
||||
private app: Express;
|
||||
|
@ -12,10 +12,10 @@ export function CreateHandler(services: Services): RequestHandler {
|
||||
const createUser = Create(services);
|
||||
|
||||
return async (req, res) => {
|
||||
const user = await createUser(req.get("request-id"), req.body);
|
||||
const user = await createUser(req.get('request-id'), req.body);
|
||||
|
||||
res.send(user);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function getRoutes(services: Services) {
|
||||
@ -26,5 +26,3 @@ export function getRoutes(services: Services) {
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { MongoClient, Db } from "mongodb";
|
||||
import { MongoClient, Db } from 'mongodb';
|
||||
|
||||
class Mongo {
|
||||
private client: MongoClient;
|
||||
|
@ -1,14 +1,16 @@
|
||||
import { CreateUserBody, User, UserInfo } from "@core";
|
||||
import { Services } from "../express/server";
|
||||
import { CreateUserBody, User, UserInfo } from '@core';
|
||||
import { Services } from '../express/server';
|
||||
|
||||
export function Create(services: Services): (tracker: string, user: CreateUserBody) => Promise<UserInfo> {
|
||||
export function Create(
|
||||
services: Services,
|
||||
): (tracker: string, user: CreateUserBody) => Promise<UserInfo> {
|
||||
const { db } = services;
|
||||
const coll = db.collection("users");
|
||||
const coll = db.collection('users');
|
||||
|
||||
return async (tracker, user) => {
|
||||
await coll.insertOne(user);
|
||||
return {
|
||||
name: "test"
|
||||
}
|
||||
}
|
||||
name: 'test',
|
||||
};
|
||||
};
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
import { CreateUserBody, UserInfo } from "@core";
|
||||
import { Services } from "../framework/express/server";
|
||||
import * as mongo from "../framework/mongo/user";
|
||||
import { CreateUserBody, UserInfo } from '@core';
|
||||
import { Services } from '../framework/express/server';
|
||||
import * as mongo from '../framework/mongo/user';
|
||||
|
||||
export function Create(services: Services): (tracker: string, user: CreateUserBody) => Promise<UserInfo> {
|
||||
export function Create(
|
||||
services: Services,
|
||||
): (tracker: string, user: CreateUserBody) => Promise<UserInfo> {
|
||||
const createUser = mongo.Create(services);
|
||||
|
||||
return async (tracker, user) => {
|
||||
return createUser(tracker, user);
|
||||
}
|
||||
};
|
||||
}
|
@ -7,21 +7,12 @@
|
||||
"outDir": "dist",
|
||||
"sourceMap": false,
|
||||
"paths": {
|
||||
"@core": [
|
||||
"../core/src"
|
||||
]
|
||||
"@core": ["../core/src"]
|
||||
}
|
||||
},
|
||||
"lib": [
|
||||
"es2015"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"dist/*"
|
||||
],
|
||||
"lib": ["es2015"],
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "dist/*"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core"
|
||||
|
22
core/package-lock.json
generated
22
core/package-lock.json
generated
@ -8,9 +8,25 @@
|
||||
"name": "core",
|
||||
"version": "1.0.0",
|
||||
"devDependencies": {
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^4.8.3"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
|
||||
@ -26,6 +42,12 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
|
||||
|
@ -5,9 +5,11 @@
|
||||
"author": "Yanis Rigaudeau - Axel Barault",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc"
|
||||
"build": "tsc",
|
||||
"prettier": "prettier -w ./src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^4.8.3"
|
||||
}
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
export * from './user';
|
||||
export * from './entity';
|
||||
export * from "./user";
|
||||
export * from "./entity";
|
||||
|
@ -2,7 +2,7 @@ import { Entity } from "./entity";
|
||||
|
||||
export type UserInfo = {
|
||||
name: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type User = UserInfo & Entity;
|
||||
|
||||
|
@ -6,12 +6,7 @@
|
||||
"sourceMap": false,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"dist/*"
|
||||
],
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "dist/*"],
|
||||
"references": []
|
||||
}
|
22
www/package-lock.json
generated
22
www/package-lock.json
generated
@ -18,6 +18,7 @@
|
||||
"@rollup/plugin-typescript": "^8.0.0",
|
||||
"@tsconfig/svelte": "^2.0.0",
|
||||
"@types/three": "^0.144.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-css-only": "^3.1.0",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
@ -1011,6 +1012,21 @@
|
||||
"url": "https://github.com/sponsors/jonschlinkert"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/queue-microtask": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
||||
@ -2359,6 +2375,12 @@
|
||||
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
|
||||
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
|
||||
"dev": true
|
||||
},
|
||||
"queue-microtask": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
|
||||
|
@ -8,7 +8,8 @@
|
||||
"build": "rollup -c",
|
||||
"dev": "rollup -c -w ",
|
||||
"start": "sirv public --no-clear --host",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"prettier": "prettier -w ./src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
@ -16,6 +17,7 @@
|
||||
"@rollup/plugin-typescript": "^8.0.0",
|
||||
"@tsconfig/svelte": "^2.0.0",
|
||||
"@types/three": "^0.144.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-css-only": "^3.1.0",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
|
@ -19,14 +19,18 @@ function serve() {
|
||||
return {
|
||||
writeBundle() {
|
||||
if (server) return;
|
||||
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||
server = require('child_process').spawn(
|
||||
'npm',
|
||||
['run', 'start', '--', '--dev'],
|
||||
{
|
||||
stdio: ['ignore', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
});
|
||||
shell: true,
|
||||
},
|
||||
);
|
||||
|
||||
process.on('SIGTERM', toExit);
|
||||
process.on('exit', toExit);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -36,15 +40,15 @@ export default {
|
||||
sourcemap: true,
|
||||
format: 'iife',
|
||||
name: 'app',
|
||||
file: 'public/build/bundle.js'
|
||||
file: 'public/build/bundle.js',
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
preprocess: sveltePreprocess({ sourceMap: !production }),
|
||||
compilerOptions: {
|
||||
// enable run-time checks when not in production
|
||||
dev: !production
|
||||
}
|
||||
dev: !production,
|
||||
},
|
||||
}),
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
@ -58,12 +62,12 @@ export default {
|
||||
resolve({
|
||||
main: true,
|
||||
browser: true,
|
||||
dedupe: ['svelte']
|
||||
dedupe: ['svelte'],
|
||||
}),
|
||||
commonjs(),
|
||||
typescript({
|
||||
sourceMap: !production,
|
||||
inlineSources: !production
|
||||
inlineSources: !production,
|
||||
}),
|
||||
|
||||
// In dev mode, call `npm run start` once
|
||||
@ -76,9 +80,9 @@ export default {
|
||||
|
||||
// If we're building for production (npm run build
|
||||
// instead of npm run dev), minify
|
||||
production && terser()
|
||||
production && terser(),
|
||||
],
|
||||
watch: {
|
||||
clearScreen: false
|
||||
}
|
||||
clearScreen: false,
|
||||
},
|
||||
};
|
||||
|
@ -2,7 +2,7 @@ import App from './App.svelte';
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
props: {}
|
||||
props: {},
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
@ -3,18 +3,11 @@
|
||||
"compilerOptions": {
|
||||
"sourceMap": false,
|
||||
"paths": {
|
||||
"@core": [
|
||||
"../core/src"
|
||||
]
|
||||
"@core": ["../core/src"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"public/*"
|
||||
],
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "public/*"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../core"
|
||||
|
Loading…
x
Reference in New Issue
Block a user