added users and groups
This commit is contained in:
		
							
								
								
									
										9
									
								
								src/utils/jwt.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/utils/jwt.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
import jwt from 'jsonwebtoken';
 | 
			
		||||
import config from '../../config.json' with {type: "json"};
 | 
			
		||||
 | 
			
		||||
const genToken = (login) => {
 | 
			
		||||
    const payload = { login };
 | 
			
		||||
    return jwt.sign(payload, config.secret, {expiresIn: "7d"});
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default genToken;
 | 
			
		||||
							
								
								
									
										24
									
								
								src/utils/log.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/utils/log.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
import config from '../../config.json' with {type: "json"};
 | 
			
		||||
 | 
			
		||||
const debug = (text) => {
 | 
			
		||||
    if (config.debug) console.debug(`[D] [${Date()}]: ${text}`)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const info = (text) => {
 | 
			
		||||
    console.log(`[I] [${Date()}]: ${text}`)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const error = (text) => {
 | 
			
		||||
    console.error(`[E] [${Date()}]: ${text}`)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const warn = (text) => {
 | 
			
		||||
    console.warn(`[W] [${Date()}]: ${text}`)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const unknownError = (text) => {
 | 
			
		||||
    error(text);
 | 
			
		||||
    return "Unknown server error. Please, report to the developer"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default { debug, info, error, warn, unknownError }
 | 
			
		||||
							
								
								
									
										7
									
								
								src/utils/status.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/utils/status.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
const statuses = {
 | 
			
		||||
    ok: "ok",
 | 
			
		||||
    duplicate: "duplicate",
 | 
			
		||||
    not_found: "not found"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default statuses
 | 
			
		||||
		Reference in New Issue
	
	Block a user