добвлены файлы

parent 0080957a
import express, {Express, json, urlencoded} from 'express';
import 'dotenv/config';
import cors from 'cors';
import {mongoose} from './repository/mongoose';
mongoose.run();
const app: Express = express();
app.use(json());
app.use(cors());
app.use(urlencoded({extended: true}));
app.use(express.static('public/uploads'));
app.listen(process.env.PORT, () => {
console.log(`App started on port ${process.env.PORT}`);
});
import {connect, connection} from 'mongoose';
export const mongoose = {
run: async () => {
try {
return await connect(`${process.env.MONGO_URL}/hw92`);
} catch (error) {
console.log(error);
}
},
stop: async () => {
try {
return await connection.destroy();
} catch (error) {
console.log(error);
}
},
};
declare global {
namespace NodeJS {
interface ProcessEnv {
PORT: string;
MONGO_URL: string;
}
}
}
export {};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment