-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Countries API #2
Changes from all commits
aa15302
524bbc7
a883159
716567e
4b3cf54
2ad1e04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import mongoose, { Schema, Document } from 'mongoose' | ||
|
||
interface ISight extends Document { | ||
titleEN: string | ||
titleRU: string | ||
titleDE: string | ||
infoEN: string | ||
infoRU: string | ||
infoDE: string | ||
pictureURL: string | ||
} | ||
|
||
export interface ICountry extends Document { | ||
id: string | ||
nameEN: string | ||
nameRU: string | ||
nameDE: string | ||
capitalEN: string | ||
capitalRU: string | ||
capitalDE: string | ||
capitalLatLng: [Number, Number] | ||
infoEN: string | ||
infoRU: string | ||
infoDE: string | ||
currency: string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Есть подозрение, что currency - это сложный тип с идентификатором валют и наименованиями на разных языках, может быть, символом. Предлагаю это обсудить There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Предлагаю делать тут трехбуквенное обозначение - USD, RUB... |
||
pictureURL: string | ||
videoURL: string | ||
sights: ISight[] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Запятых в конце строки отсыпь, пожалуйста ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sights: Array |
||
} | ||
|
||
export const CountrySchema: Schema = new Schema({ | ||
id: { type: String, required: true, unique: true }, | ||
nameEN: { type: String, required: true, unique: true }, | ||
nameRU: { type: String, required: true, unique: true }, | ||
nameDE: { type: String, required: true, unique: true }, | ||
capitalEN: { type: String, required: true, unique: true }, | ||
capitalRU: { type: String, required: true, unique: true }, | ||
capitalDE: { type: String, required: true, unique: true }, | ||
capitalLatLng: { type: Array, required: true, unique: true }, | ||
infoEN: { type: String, required: true }, | ||
infoRU: { type: String, required: true }, | ||
infoDE: { type: String, required: true }, | ||
currency: { type: String, required: true }, | ||
pictureURL: { type: String, required: true }, | ||
videoURL: { type: String, required: true }, | ||
sights: { type: Array, required: true }, | ||
}) | ||
|
||
export const Countries = mongoose.model<ICountry>('Countries', CountrySchema); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import express from 'express' | ||
import { Countries } from '../models/countries' | ||
|
||
export const countriesRouter: express.Router = express.Router() | ||
|
||
countriesRouter.get( | ||
'/', | ||
async (req: express.Request, res: express.Response, next: express.NextFunction) => { | ||
const countries = await Countries.find({}, { _id: 0 }) | ||
res.json(countries) | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не хватает пустой строки
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed