Skip to content
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] Added download apk file #263

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ [email protected]
MAIL_PASSWORD=test
PROD=false
HTTPS=false
LOGGER=true
LOGGER=true
APK_PATH=/var/apk
29 changes: 29 additions & 0 deletions src/routes/user/downloadApk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @memberof module:router~mainRouter~userRouter
* @inner
* @namespace downloadApk
*/
const Logger = require('../../services/logger')

/**
* Main download apk function
* @name GET /user/file/:id
* @function
* @memberof module:router~mainRouter~userRouter~downloadApk
* @inner
* @async
* @param {Object} req
* @param {Object} res
* @returns 200 if OK
* @returns 500 if Internal Server Error
*/
module.exports = async (req, res) => {
try {
const path = process.env.APK_PATH

return res.status(200).download(path, 'schood.apk')
} catch (error) /* istanbul ignore next */ {
Logger.error(error)
return res.status(500).json({ message: 'Internal Server Error' })
}
}
2 changes: 2 additions & 0 deletions src/routes/user/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const downloadFile = require('./downloadFile')
const getFacility = require('./getFacility')
const modifyProfile = require('./modifyProfile')
const tokenCheck = require('./tokenCheck')
const downloadApk = require('./downloadApk')

/**
* User router connection
Expand All @@ -44,6 +45,7 @@ router.get('/profile', auth, profile)
router.get('/by/:position', auth, access(2, false), getUsersByPosition)
router.get('/all', auth, access(2, false), getAllUsers)
router.get('/tokenCheck', auth, tokenCheck)
router.get('/downloadApk', downloadApk)
router.patch('/:id', auth, access(1), updateUser)

// helpNumbers
Expand Down