app moved to next.js
This commit is contained in:
1 parent
dcca513aea
commit
43af2996bf
48 files changed
+1147
-1027
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Teacher from '../../../src/core/Teacher'
|
||||
import { encodePerson } from '../../../src/api/persons'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const id = req.query.person
|
||||
const person = await Teacher.findById(id)
|
||||
const data = encodePerson(person)
|
||||
|
||||
if (data) {
|
||||
res.json(data)
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { dbUri } from '../../../src/config'
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Teacher from '../../../src/core/Teacher'
|
||||
import { prioritySort } from '../../../src/lib/sort'
|
||||
import { encodePerson } from '../../../src/api/persons'
|
||||
|
||||
export default async (req, res) => {
|
||||
await connect(dbUri)
|
||||
|
||||
const order = [
|
||||
'mg-timasheva',
|
||||
'va-sarzhin',
|
||||
'od-gogoleva',
|
||||
'my-valkova',
|
||||
'nv-andreeva',
|
||||
'vv-voronova',
|
||||
]
|
||||
const teachersSorted = prioritySort.bind(null, [...order], t => t.id)
|
||||
|
||||
const teachers = await Teacher.find({ hidden: false })
|
||||
const data = teachersSorted(teachers).map(encodePerson)
|
||||
|
||||
if (data) {
|
||||
res.json({
|
||||
items: data,
|
||||
})
|
||||
} else {
|
||||
res.status(404)
|
||||
res.json({
|
||||
error: `Article ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user