Based off of: http://docs.sequelizejs.com/en/1.7.0/articles/express/
Create and initialize your a directory for your Express application.
$ mkdir sequelize-demo| #!/bin/bash | |
| docker rm --force $(docker ps --all -q) | |
| docker rmi --force $(docker images --all -q) |
Back in 2010, Vincent Driessen wrote a post called
A successful Git branching model.
Besides being extremely well drafted and clear in it's intention, the post goes
into great detail about Git branching strategies and release management. The
model that Vincent (sobriquet "nvie") came up with was popularized as git-flow.
| // List all files in a directory in Node.js recursively in a synchronous fashion | |
| var walkSync = function(dir, filelist) { | |
| var fs = fs || require('fs'), | |
| files = fs.readdirSync(dir); | |
| filelist = filelist || []; | |
| files.forEach(function(file) { | |
| if (fs.statSync(dir + file).isDirectory()) { | |
| filelist = walkSync(dir + file + '/', filelist); | |
| } | |
| else { |
| class CircuitBreaker { | |
| constructor(request) { | |
| this.request = request | |
| this.state = "CLOSED" | |
| this.failureThreshold = 3 | |
| this.failureCount = 0 | |
| this.successThreshold = 2 | |
| this.successCount = 0 | |
| this.timeout = 6000 | |
| this.nextAttempt = Date.now() |
- Change your database RDS instance security group to allow your machine to access it.
- Add your ip to the security group to acces the instance via Postgres.
- Make a copy of the database using pg_dump
$ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>- you will be asked for postgressql password.
- a dump file(.sql) will be created
- Restore that dump file to your local database.
- but you might need to drop the database and create it first
$ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
- the database is restored
| import { NamingStrategyInterface, DefaultNamingStrategy } from 'typeorm' | |
| import { snakeCase } from 'typeorm/util/StringUtils' | |
| export class SnakeNamingStrategy extends DefaultNamingStrategy implements NamingStrategyInterface { | |
| tableName(className: string, customName: string): string { | |
| return customName ? customName : snakeCase(className) | |
| } | |
| columnName(propertyName: string, customName: string, embeddedPrefixes: string[]): string { | |
| return snakeCase(embeddedPrefixes.join('_')) + (customName ? customName : snakeCase(propertyName)) |
Important: I'm writing this when the last version of macOS (and the one I have installed) is Mojave. There is already a script which installs Mojave in a virtual machine here https://github.com/img2tab/okiomov. But if you are curios how to do everything manually to install High Sierra, then this guide may be useful.
After reading a few articles I ended up with these steps:
- On macOS, download the High Sierra installer (even if you have Mojave installed): https://itunes.apple.com/us/app/macos-high-sierra/id1246284741?ls=1&mt=12
- If the High Sierra Installer starts, quit it.
- Open "Disk Utility".
- Click on "File" > "New Image" > "Blank image...". Or just press cmd+N.
I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.
Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:
fetch("/api/foo")
.then( response => {
if (!response.ok) { throw response }
return response.json() //we only get here if there is no error
})

