Commit 11ef6884 authored by Рахметова Альбина's avatar Рахметова Альбина

Merge branch '5' into 'dev'

5

See merge request !5
parents 0080957a 3672353c
MONGO_URL='mongodb://localhost:27017'
PORT='3000'
\ No newline at end of file
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 {};
This diff is collapsed.
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