Node.js Express JSON API - CRUD Stickers We'll be using:
Postgres for our database
knex.js for our database migrations, seeds and queries.
express.js for our JSON routes
Mocha, Chai and SuperTest to test our routes
# Stage 1 - build environment | |
FROM node:8.15-alpine as builder | |
WORKDIR /usr/src/app/ | |
COPY . ./ | |
RUN npm install --production | |
RUN npm run build | |
# Stage 2- production environment | |
FROM nginx:alpine | |
COPY nginx.conf /etc/nginx/conf.d/default.conf | |
COPY --from=builder /usr/src/app/build/ /usr/share/nginx/html/ |
Node.js Express JSON API - CRUD Stickers We'll be using:
Postgres for our database
knex.js for our database migrations, seeds and queries.
express.js for our JSON routes
Mocha, Chai and SuperTest to test our routes
[Desktop Entry] | |
Encoding=UTF-8 | |
Name=Postman | |
Exec=postman | |
Icon=/home/USERNAME/Postman/app/resources/app/assets/icon.png | |
Terminal=false | |
Type=Application | |
Categories=Development; |
// file: index.js | |
var _ = require("lodash"); | |
var express = require("express"); | |
var bodyParser = require("body-parser"); | |
var jwt = require('jsonwebtoken'); | |
var passport = require("passport"); | |
var passportJWT = require("passport-jwt"); |
Create React apps with no build configuration.
Thanks to create-react-app. It's saves a lot of my time. I remember several months ago I had to setup a lot just for a react app, webpack, babel, test environment and so on... Fortunately, everything becomes easy now. Though you have many choices of start boiler plate, you worth trying this.
If you are build a SPA with react, you probably use react-router
.
#!/bin/bash | |
# Get postman app | |
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz | |
sudo tar -xzf postman.tar.gz -C /opt | |
sudo ln -s /opt/Postman/Postman /usr/bin/postman | |
#Create a Desktop Entry | |
cat > ~/.local/share/applications/postman.desktop <<EOL | |
[Desktop Entry] | |
Encoding=UTF-8 |
def increment_string(input) | |
#your code here | |
s = input | |
s_digits = input.slice!(/\d+/) | |
s_digits_length = s_digits.length | |
end |
def gcd(n, m) | |
if (n > m) && (n * m > 0) | |
r = n % m | |
if r == 0 | |
return m | |
else | |
return gcd(m, r) | |
end | |
end |