add prettier

This commit is contained in:
2023-08-06 09:21:17 +03:00
parent cc453e2337
commit feb5e5b4ca
25 changed files with 524 additions and 591 deletions

View File

@@ -1,27 +1,19 @@
import { randomUUID } from "crypto";
import { feathers } from "@feathersjs/feathers";
import express, {
rest,
json,
urlencoded,
cors,
serveStatic,
notFound,
errorHandler,
} from "@feathersjs/express";
import configuration from "@feathersjs/configuration";
import socketio from "@feathersjs/socketio";
import session from "express-session";
import cookieParser from "cookie-parser";
import RedisStore from "connect-redis";
import { createClient } from "redis";
import config from "config";
import type { Application } from "./declarations";
import { logger } from "./logger";
import { logError } from "./hooks/log-error";
import { services } from "./services/index";
import { channels } from "./channels";
import { Env, getEnv } from "./helpers/get-env";
import { randomUUID } from 'crypto';
import { feathers } from '@feathersjs/feathers';
import express, { rest, json, urlencoded, cors, serveStatic, notFound, errorHandler } from '@feathersjs/express';
import configuration from '@feathersjs/configuration';
import socketio from '@feathersjs/socketio';
import session from 'express-session';
import cookieParser from 'cookie-parser';
import RedisStore from 'connect-redis';
import { createClient } from 'redis';
import config from 'config';
import type { Application } from './declarations';
import { logger } from './logger';
import { logError } from './hooks/log-error';
import { services } from './services/index';
import { channels } from './channels';
import { Env, getEnv } from './helpers/get-env';
const app: Application = express(feathers());
@@ -29,54 +21,54 @@ const app: Application = express(feathers());
app.configure(configuration());
app.use(cors());
app.use(
json({
limit: "20mb",
}),
json({
limit: '20mb',
})
);
app.use(cookieParser());
const sessionStore =
getEnv() === Env.prod
? new RedisStore({
prefix: "walias:",
client: createClient({
url: config.get("redis.url"),
}),
})
: undefined;
getEnv() === Env.prod
? new RedisStore({
prefix: 'walias:',
client: createClient({
url: config.get('redis.url'),
}),
})
: undefined;
app.use(
session({
store: sessionStore,
secret: randomUUID(),
resave: false,
saveUninitialized: false,
cookie: { secure: false },
}),
session({
store: sessionStore,
secret: randomUUID(),
resave: false,
saveUninitialized: false,
cookie: { secure: false },
})
);
// Propagate session to request.params in feathers services
app.use(function (req, _res, next) {
req.feathers = {
...req.feathers,
session: req.session,
};
next();
req.feathers = {
...req.feathers,
session: req.session,
};
next();
});
app.use(urlencoded({ extended: true }));
// Host the public folder
app.use("/", serveStatic(app.get("public")));
app.use('/', serveStatic(app.get('public')));
// Configure services and real-time functionality
app.configure(rest());
app.configure(
socketio({
cors: {
origin: app.get("origins"),
},
}),
socketio({
cors: {
origin: app.get('origins'),
},
})
);
app.configure(services);
app.configure(channels);
@@ -87,17 +79,17 @@ app.use(errorHandler({ logger }));
// Register hooks that run on all service methods
app.hooks({
around: {
all: [logError],
},
before: {},
after: {},
error: {},
around: {
all: [logError],
},
before: {},
after: {},
error: {},
});
// Register application setup and teardown hooks here
app.hooks({
setup: [],
teardown: [],
setup: [],
teardown: [],
});
export { app };