add withMiddleware for all api routes. Now it do nothing
This commit is contained in:
1 parent
cd7536f74f
commit
95c8369df2
16 files changed
+48
-30
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Document from '../../../src/core/Document'
|
||||
import { encodeFile } from '../../../src/api/files'
|
||||
import { withMiddleware } from '../../../src/middlewares/withMiddleware'
|
||||
|
||||
export default async (req, res) => {
|
||||
export default withMiddleware(async (req, res) => {
|
||||
await connect()
|
||||
|
||||
const id = req.query.document
|
||||
@@ -16,4 +17,4 @@ export default async (req, res) => {
|
||||
error: `Document ${id} not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,8 +1,9 @@
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Document from '../../../src/core/Document'
|
||||
import { encodeFile } from '../../../src/api/files'
|
||||
import { withMiddleware } from '../../../src/middlewares/withMiddleware'
|
||||
|
||||
export default async (req, res) => {
|
||||
export default withMiddleware(async (req, res) => {
|
||||
await connect()
|
||||
|
||||
const documents = await Document.find({hidden: false})
|
||||
@@ -20,4 +21,4 @@ export default async (req, res) => {
|
||||
error: `Documents not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1,8 @@
|
||||
import { connect } from '../../../src/core/db'
|
||||
import Document from '../../../src/core/Document'
|
||||
import { withMiddleware } from '../../../src/middlewares/withMiddleware'
|
||||
|
||||
export default async (req, res) => {
|
||||
export default withMiddleware(async (req, res) => {
|
||||
await connect()
|
||||
|
||||
const data = await Document.find({})
|
||||
@@ -17,4 +18,4 @@ export default async (req, res) => {
|
||||
error: `Not found`
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user