This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // string | |
| let nama: string = 'Nauval'; | |
| nama = 'Shidqi Ganteng'; | |
| // number | |
| let umur: number = 12; | |
| umur = 6; | |
| let angka = <number>umur; // cara lain deklarasi variable Type Assertion | |
| console.log('angka', angka); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Full docs: https://joi.dev/api/?v=17.4.0 | |
| const Joi = require('joi'); | |
| try { | |
| const schema = Joi.object().keys({ | |
| name: Joi.string().min(2).required().messages({ | |
| 'string.base': `"username" should be a type of 'text'`, | |
| 'string.empty': `"username" cannot be an empty field`, | |
| 'string.min': `"username" should have a minimum length of {#limit}`, | |
| 'any.required': `"username" is a required field`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Error: Ngirim email menggunakan nodemailer & smtp google, di pc local lancar di production gagal. | |
| Error Message: Error: connect ECONNREFUSED,code: ESOCKET, port: 45 | |
| Sebelumnya: | |
| nodemailer.createTransport({ | |
| service: 'Gmail', | |
| auth: { | |
| user: 'xx', | |
| pass: 'xx', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Install: https://www.2ndquadrant.com/en/blog/pginstaller-install-postgresql/ | |
| -- Env postgresn in windows: https://sqlbackupandftp.com/blog/setting-windows-path-for-postgres-tools | |
| -- Nyalain service | |
| -- Run (Win + R) -> services.msc | |
| -- Cari PostgreSQL -> klik kanan -> start | |
| -- Menjalankan perintah SQL di CMD | |
| -- cd C:\Program Files\2ndQuadrant\PostgreSQL\12\bin | |
| -- psql.exe -U postgres |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Cara penulisan triggers | |
| DELIMITER $$ | |
| CREATE TRIGGER nama_trigger | |
| {BEFORE | AFTER} {INSERT | UPDATE| DELETE } | |
| ON nama_table | |
| FOR EACH ROW | |
| BEGIN | |
| KODE SQL | |
| END$$ | |
| DELIMITER ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Aktifkan event scheduler | |
| SET GLOBAL event_scheduler := 1; | |
| SELECT @@event_scheduler; | |
| -- Menampilkan events yang ada pada db | |
| SHOW EVENTS; | |
| -- Contoh | |
| -- nama event: event_payments | |
| CREATE EVENT `event_payments` ON SCHEDULE EVERY 1 MINUTE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Back up db | |
| # 0 0 * * * => everyday at 00:00 | |
| mysqldump -u user_name -p'your_password' -h127.0.0.1 db_name | gzip > /home/dreamtechnology/logistics/backups/backup_$(date +"\%Y.\%m.\%d.\%S.\%N").sql.gz | |
| # Curl | |
| # */5 * * * * => every 5 minute | |
| curl -m 120 -s http://api.xxx.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AppError extends Error { | |
| constructor(message, statusCode) { | |
| super(message); | |
| this.statusCode = statusCode; | |
| this.status = `${statusCode}`.startsWith('4') ? 'fail' : 'error'; | |
| this.isOperational = true; | |
| Error.captureStackTrace(this, this.constructor); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| module.exports = { | |
| up: async (queryInterface, Sequelize) => { | |
| await queryInterface.createTable('stores', { | |
| id: { | |
| allowNull: false, | |
| autoIncrement: true, | |
| primaryKey: true, | |
| type: Sequelize.INTEGER | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://speakerdeck.com/rottmann/api-documentation?slide=14 | |
| https://indrakusuma.web.id/2017/11/09/Tutorial-Buat-Dokumentasi-RESTful-API-dengan-APIdocJS/ |