Skip to content

Commit

Permalink
add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey authored and Andrey committed Nov 10, 2022
0 parents commit 973a3ef
Show file tree
Hide file tree
Showing 34 changed files with 10,478 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
env: {
commonjs: true,
es2021: true,
node: true,
jest: true,
},
extends: ["standard", "prettier"],
parserOptions: {
ecmaVersion: 12,
},
rules: {},
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.env
12 changes: 12 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 150,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
"proseWrap": "always"
}
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["node", "server"]
30 changes: 30 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require("express");
const logger = require("morgan");
const cors = require("cors");
require("dotenv").config();

const newsRouter = require("./routes/news");
const friendsRouter = require("./routes/friends");

const app = express();

const formatsLogger = app.get("env") === "development" ? "dev" : "short";

app.use(logger(formatsLogger));
app.use(cors());
app.use(express.json());
app.use(express.static("public"));

app.use("/news", newsRouter);
app.use("/friends", friendsRouter);

app.use((req, res) => {
res.status(404).json({ message: "Not found" });
});

app.use((err, req, res, next) => {
const { status = 500, message = "Server error" } = err;
res.status(status).json({ message });
});

module.exports = app;
12 changes: 12 additions & 0 deletions controllers/friends/getAll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { Friends } = require("../../models/friends");

const getAll = async (req, res) => {
const friends = await Friends.find({});

res.json({
message: "success",
data: { result: friends },
});
};

module.exports = getAll;
5 changes: 5 additions & 0 deletions controllers/friends/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const getAll = require("./getAll");

module.exports = {
getAll,
};
7 changes: 7 additions & 0 deletions controllers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const news = require("./news");
const friends = require("./friends");

module.exports = {
news,
friends,
};
12 changes: 12 additions & 0 deletions controllers/news/getAll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { News } = require("../../models/news");

const getAll = async (req, res) => {
const news = await News.find({});

res.json({
message: "success",
data: { result: news },
});
};

module.exports = getAll;
5 changes: 5 additions & 0 deletions controllers/news/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const getAll = require("./getAll");

module.exports = {
getAll,
};
8 changes: 8 additions & 0 deletions env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DB_HOST=
SECRET_KEY=
CLOUD_NAME=
CLOUD_KEY=
CLOUD_SECRET=
SENDGRID_API_KEY=
SENDER_EMAIL_ADRESS=
BASE_URL=
12 changes: 12 additions & 0 deletions helpers/ctrlWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const ctrlWrapper = (ctrl) => {
const func = async (req, res, next) => {
try {
await ctrl(req, res, next);
} catch (error) {
next(error);
}
};
return func;
};

module.exports = ctrlWrapper;
7 changes: 7 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const ctrlWrapper = require("./ctrlWrapper");
const requestError = require("./requestError");

module.exports = {
ctrlWrapper,
requestError,
};
15 changes: 15 additions & 0 deletions helpers/requestError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const messages = {
400: 'Bad requsest',
401: 'Unauthorized',
403: 'Forbidden',
404: 'Not found',
};

const RequestError = (status, message = messages[status]) => {
const error = new Error(message);
error.status = status;

return error;
};

module.exports = RequestError;
Empty file added middleware/test
Empty file.
36 changes: 36 additions & 0 deletions models/friends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const { Schema, model } = require("mongoose");

const newsSchema = Schema(
{
name: {
type: String,
required: true,
unique: true,
},
time: {
type: String,
},
adress: {
type: String,
},
phone: {
type: String,
},
email: {
type: String,
},
logo: {
type: String,
},
link: {
type: String,
},
},
{ versionKey: false }
);

const Friends = model("friends", newsSchema);

module.exports = {
Friends,
};
139 changes: 139 additions & 0 deletions models/friends.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[
{
"name": "Барбос",
"time": {
"MN": "8:00- 20:00",
"TU": "8:00- 20:00",
"WE": "8:00- 20:00",
"TH": "8:00- 20:00",
"FR": "8:00- 20:00",
"SA": "8:00- 20:00",
"SU": "8:00- 20:00"
},
"adress": "Grigorenka Street, 25 ",
"phone": "+3110 44 290-03-29",
"email": "barbos@gmail.com",
"logo": "https://s.0312.ua/section/newsInText/upload/images/news/intext/000/050/1113/barbos-logo_5c0711b136ea2f.jpg",
"link": "https://www.facebook.com/NGO.Barbos"
},
{
"name": "Whiskas",
"time": {
"MN": "8:00- 19:00",
"TU": "8:00- 19:00",
"WE": "8:00- 19:00",
"TH": "8:00- 19:00",
"FR": "8:00- 19:00",
"SA": "8:00- 19:00",
"SU": "8:00- 19:00"
},
"adress": "------------",
"phone": "0-1100-500-155",
"email": "whiskas@gmail.com",
"logo": "https://www.whiskas.ua/Content/img/public/logo.png",
"link": "https://www.whiskas.ua/"
},
{
"name": "ЛКП 'ЛЕВ' ",
"time": {
"MN": "8:00- 19:00",
"TU": "8:00- 19:00",
"WE": "8:00- 19:00",
"TH": "8:00- 19:00",
"FR": "8:00- 19:00",
"SA": "8:00- 19:00",
"SU": "8:00- 19:00"
},
"adress": "Promyslova Street, 56 ",
"phone": "(068) 535-45-45",
"email": "lkplev@gmail.com",
"logo": "https://lkplev.com/images/logo.png",
"link": "https://lkplev.com/"
},
{
"name": "Happy paw",
"time": {
"MN": "09:00- 19:00",
"TU": "09:00- 19:00",
"WE": "09:00- 19:00",
"TH": "09:00- 19:00",
"FR": "09:00- 19:00",
"SA": "09:00- 19:00",
"SU": "09:00- 19:00"
},
"adress": "Chota Rystaveli Street, 44",
"phone": "+380 44 290-03-29",
"email": "hello@happypaw.ua",
"logo": "",
"link": "https://happypaw.ua/ua/"
},
{
"name": "PetHelp",
"time": {},
"adress": "------------",
"phone": "------------",
"email": "pithelp.ukr@gmail.com",
"logo": "https://pethelp.com.ua/images/logo3.png",
"link": "https://pethelp.com.ua/"
},
{
"name": "Сіріус",
"time": {
"MN": "11:00- 16:00",
"TU": "11:00- 16:00",
"WE": "11:00- 16:00",
"TH": "11:00- 16:00",
"FR": "11:00- 16:00",
"SA": "11:00- 16:00",
"SU": "11:00- 16:00"
},
"adress": "Fedorivka, Kyiv Oblast",
"phone": "+38 093 193 40 69",
"email": "dogcat.sirius@gmail.com",
"logo": "https://dogcat.com.ua/images/logo-horizontal.svg",
"link": "https://dogcat.com.ua/"
},
{
"name": "PURINA",
"time": {},
"adress": "------------",
"phone": "1-800-778-7462",
"email": "info@ua.nestle.com",
"logo": "https://www.whiskas.ua/Content/img/public/logo.png",
"link": "https://www.purina.ua/"
},
{
"name": "Josera",
"time": {
"MN": "09:00- 17:00",
"TU": "09:00- 17:00",
"WE": "09:00- 17:00",
"TH": "09:00- 17:00",
"FR": "09:00- 17:00",
"SA": "09:00- 17:00",
"SU": "09:00- 17:00"
},
"adress": "Sholom-Aleikhema St, 11",
"phone": "0 800 409 060",
"email": "info@josera.ua",
"logo": "https://josera.ua/static/frontend/Magecom/josera/uk_UA/images/logo.svg",
"link": "https://josera.ua/"
},
{
"name": "LICO",
"time": {
"MN": "09:00- 20:00",
"TU": "09:00- 20:00",
"WE": "09:00- 20:00",
"TH": "09:00- 20:00",
"FR": "09:00- 20:00",
"SA": "09:00- 20:00",
"SU": "09:00- 20:00"
},
"adress": "Dryhetiv Street, 77",
"phone": "+38 097 509 8005",
"email": "lico@gmail.com",
"logo": "https://lico.vet/wp-content/uploads/2020/11/licoveterinary-e1605477412808.png",
"link": "https://lico.vet/"
}
]
28 changes: 28 additions & 0 deletions models/news.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { Schema, model } = require("mongoose");

const newsSchema = Schema(
{
title: {
type: String,
required: [true, "Set name for contact"],
unique: true,
},
description: {
type: String,
},
date: {
type: String,
default: "12/11/2022",
},
link: {
type: String,
},
},
{ versionKey: false }
);

const News = model("news", newsSchema);

module.exports = {
News,
};
Loading

0 comments on commit 973a3ef

Please sign in to comment.