Index

src/core/crypto/crypto.ts

algorithm
Type : string
Default value : 'aes-256-gcm'
decrypt
Default value : (config: ConfigService, data: any) => { try { // constant to decrypt the data const inputEncoding = 'base64'; const outputEncoding = 'utf8'; // Creates a new Buffer containing the given JavaScript string {str} const bufferData = Buffer.from(data, inputEncoding); // password - master key const password = config.get('crypto.secretKey'); // derive key using; 32 byte key length const key = crypto.pbkdf2Sync(password, salt, iterations, keylen, digest); // extract iv from encrypted data const iv = bufferData.slice(bufferData.length - 28, bufferData.length - 16); // extract tag from encrypted data const tag = bufferData.slice(bufferData.length - 16); // extract encrypted text from encrypted data const text = bufferData.slice(0, bufferData.length - 28); // AES 256 GCM Mode const decipher = crypto.createDecipheriv(algorithm, key, iv); // set the auth tag decipher.setAuthTag(tag); // Used to update the cipher with data according to the given encoding format. // @data: It is used to update the cipher by new content // @inputEncoding: Input encoding format // @outputEncoding: Output encoding format let str = decipher.update(text, null, outputEncoding); // Return the buffer containing the value of cipher object. // @outputEncoding: Output encoding format str += decipher.final(outputEncoding); // parse the string decrypted data return JSON.parse(str); } catch (exception) { throw new Error(exception); } }
digest
Type : string
Default value : 'sha512'
encrypt
Default value : (config: ConfigService, data: any) => { try { // constant to encrypt the data const inputEncoding = 'utf8'; const outputEncoding = 'base64'; // password - master key const password = config.get('crypto.secretKey'); // random initialization vector const iv = crypto.randomBytes(12); // The method gives an asynchronous Password-Based Key Derivation const key: Buffer = crypto.pbkdf2Sync(password, salt, iterations, keylen, digest); // create a Cipher object, with the stated algorithm, key and initialization vector (iv). // @algorithm - AES 256 GCM Mode // @key // @iv // @options const cipher = crypto.createCipheriv(algorithm, key, iv); // create a Cipher object, with the stated algorithm, key and initialization vector (iv). // @algorithm - AES 256 GCM Mode // @key // @iv // @options const enc1 = cipher.update(JSON.stringify(data), inputEncoding); // Return the buffer containing the value of cipher object. // @outputEncoding: Output encoding format // const enc2 = cipher.final(); const enc2 = cipher.final(); // extract the auth tag const tag = cipher.getAuthTag(); // return the result return Buffer.concat([enc1, enc2, iv, tag]).toString(outputEncoding); } catch (exception) { throw new Error(exception); } }
iterations
Type : number
Default value : 2145
keylen
Type : number
Default value : 32
salt
Default value : crypto.randomBytes(64)

src/feature/users/constants/api.response.dto.ts

apiResponse
Type : object
Default value : { apiUserCreatedResponse: 'User has been created successfully', apiUserGetResponse: 'Users list returned successfully', apiUserGetById: 'User with specified Id returned successfully', apiUserUpdatedResponse: 'User with specified id updated successfully', apiUserDeletedResponse: 'User with specified id deleted successfully', apiCreateUserFirstNameProperty: { type: 'String', description: 'Firstname of the user', }, apiCreateUserLastNameProperty: { type: 'String', description: 'Lastname of the user', }, apiUpdateUserBoolProperty: { type: 'Boolean', description: 'Tells us whether user is active or not', }, apiValidateUserEmail: { type: 'String', description: 'Email of the user', }, apiValidateUserPass: { type: 'String', description: 'Password of the user', }, }

src/core/db/typeorm.config.ts

configa
Type : ConnectionOptions
Default value : { type: 'mysql', host: process.env.DB_HOST, port: +process.env.DB_PORT, username: process.env.DB_USER, password: process.env.DB_PASSWORD, database: process.env.DB_DATABASE, entities: [User], synchronize: false, cli: { migrationsDir: 'src/db/migrations', }, }

src/core/cors.config.ts

corsOptions
Type : object
Default value : { origin: ['https://example1.com', 'https://example2.com', 'https://127.0.0.1:5500'], }

src/core/providers.ts

exportProvider
Default value : (): [any] => { return [AppLogger]; }
getProviders
Default value : (): [any] => { return [AppLogger]; }

test/mock/generate-token.stub.ts

loginCredentials
Type : object
Default value : { email: 'santoshshinde@gmail.com', password: '123456seven', }

src/swagger/index.ts

setupSwagger
Default value : (app: INestApplication) => { const config = app.get(ConfigService); const options = new DocumentBuilder() .setTitle(config.get('app.name')) .setDescription(`API Documentation for the app ${config.get('app.name')}`) .addBearerAuth( { type: 'http', scheme: 'bearer', bearerFormat: 'JWT', name: 'JWT', description: 'Enter JWT token', in: 'header', }, 'JWT-auth' ) .build(); const document = SwaggerModule.createDocument(app, options); SwaggerModule.setup('api/docs', app, document); }

src/core/compression/compression.ts

shouldCompress
Default value : (req: Request, res: Response) => { if (req.headers['x-no-compression']) { return false; } return compression.filter(req, res); }

test/mock/user.update.stub.ts

updateUserStub
Default value : () => { return { firstName: 'Santosh', lastName: 'Shinde', isActive: true, }; }

test/mock/users.response.ts

users
Type : []
Default value : [ { id: 127, firstName: 'Santosh', lastName: 'Shinde', email: 'santoshshinde@gmail.com', password: '123456seven', isActive: true, }, ]

test/mock/user.stub.ts

userStub
Default value : () => { return { firstName: 'Santosh', lastName: 'Shinde', email: 'santoshshinde@gmail.com', password: '123456seven', isActive: true, }; }

results matching ""

    No results matching ""