mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Auth system
This commit is contained in:
parent
52778532dc
commit
9435cc6533
14 changed files with 637 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
|||
module.exports = {
|
||||
ReadFile: ReadFile,
|
||||
ReadJSON: ReadJSON,
|
||||
WriteFile: WriteFile,
|
||||
writeFileAsync: WriteFileAsync,
|
||||
AppendToFile: AppendToFile,
|
||||
|
@ -27,6 +28,15 @@ function ReadDir (path) {
|
|||
return fs.readdirSync(path)
|
||||
}
|
||||
|
||||
function ReadJSON (name) {
|
||||
try {
|
||||
return JSON.parse(ReadFile(name))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
throw new Error('Coulndt parse JSON in "ReadJSON", file: ' + name)
|
||||
}
|
||||
}
|
||||
|
||||
function ReadFile (name) {
|
||||
if (!FileExists(name)) { throw new Error('No such file: ' + name) }
|
||||
return fs.readFileSync(name, 'utf8')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue