Skip to content

Instantly share code, notes, and snippets.

@boltathi24
boltathi24 / project.yml
Created Jul 27, 2021
Serverless project.yml configuration
View project.yml
bucket:
strip: 1
packages:
- name: form
actions:
- name: insert
limits:
timeout: 60000
environment:
@boltathi24
boltathi24 / index.js
Created Jul 27, 2021
Serverless function to store visitor query into MongoDB
View index.js
const mongoose = require("mongoose");
const DB_Username = process.env.DB_Username; //getting credentials from Environment variables
const DB_Password = process.env.DB_Password;
const DB_Name = process.env.DB_Name;
const DB_ClusterUri = process.env.DB_ClusterUri;
const DATABASEURI = `mongodb+srv://${DB_Username}:${DB_Password}@${DB_ClusterUri}/${DB_Name}?retryWrites=true&w=majority`;
mongoose
.connect(DATABASEURI, {
@boltathi24
boltathi24 / .include
Created Jul 27, 2021
.include file to specify file to be included while deploying to serverless
@boltathi24
boltathi24 / build.sh
Created Jul 27, 2021
build.sh to build the React App
View build.sh
npm install
rm -fr build
npm run build
@boltathi24
boltathi24 / docker-compose.yml
Created Jul 27, 2021
docker-compose.yml configuration for React App
View docker-compose.yml
version: '3.7'
services:
nameis:
container_name: devportfolio
build:
context: .
dockerfile: Dockerfile
image: react:app
@boltathi24
boltathi24 / docker-compose.yml
Created Jul 27, 2021
docker-compose.yml configuration for Express API
View docker-compose.yml
version: '3.7'
services:
nameis:
container_name: expressapi
build:
context: .
dockerfile: Dockerfile
image: express:app
@boltathi24
boltathi24 / Dockerfile
Created Jul 27, 2021
DockerFile for React App
View Dockerfile
# pull official base image
FROM node:13.12.0-alpine
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install app dependencies
@boltathi24
boltathi24 / Dockerfile
Created Jul 27, 2021
DockerFile for Express Api
View Dockerfile
# pull official base image
FROM node:13.12.0-alpine
# set working directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# install app dependencies
@boltathi24
boltathi24 / index.js
Created Jul 27, 2021
Express Api to Store visitor queries into mongoDB
View index.js
const mongoose = require("mongoose");
const express = require("express")
const bodyParser = require('body-parser');
const DB_Username = process.env.DB_Username; //getting credentials from Environment variables
const DB_Password =process.env.DB_Password;;
const DB_Name = process.env.DB_Name;
const DB_ClusterUri = process.env.DB_ClusterUri;
const DATABASEURI = `mongodb+srv://${DB_Username}:${DB_Password}@${DB_ClusterUri}/${DB_Name}?retryWrites=true&w=majority`;
const port = process.env.PORT;
const router = express.Router()