electron-react-boilerplate /
electron-react-boilerplate
A Foundation for Scalable Cross-Platform Apps
97/100 healthLoading repository data…
feredean / repository
A boilerplate for Node.js APIs designed for app consumption, written in Typescript
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
While the project can still be used for reference, the reality is that it has aged and no longer reflects best practices. To make this clear, the project is now archived.
Live App Demo: https://node-api-starter-angular-app.experiments.explabs.io
Live API: https://node-api-starter.experiments.explabs.io/v1/hello
A boilerplate for Node.js APIs designed for app consumption, written in Typescript.
This project has two purposes:
You can find the Angular App source code here https://github.com/feredean/node-api-starter-angular-app
There are two ways to go about handling requirements. You can either follow the quick start path where you dump all the dependencies in your system or you can go down the fancy setup that will give you more flexibility in the future by using nvm and docker.
.nvmrc file.docker run -d --name mongo-dev -p 27017:27017 mongo:4.0Set VSCode's Typescript import module specifier for the workspace to relative for more information have a look here
# Get the latest snapshot
git clone --depth=1 https://github.com/feredean/node-api-starter.git <project_name>
# Change directory
cd <project_name>
# Install dependencies
npm install
# Build the project
npm run build
# Copy the .env.example contents into the .env
cat .env.example > .env
# Run (development mode) the API on port 9100
npm run watch
To build the project in VS Code press cmd + shift + b. You can also run tasks using the command pallet (cmd + shift + p) and select Tasks: Run Task > npm: start to run npm start for you.
Finally, navigate to http://localhost:9100/v1/hello and you now have access to your API
For how environment variables are imported and exported have a look in src/config/secrets. Here you can also change the requiredSecrets or the way mongoURI is constructed if for example you wish to use username/password when connecting to mongo in the development environment.
| Name | Description |
|---|---|
| The session secret is used to sign the JWT tokens | |
| SESSION_SECRET | A quick way to generate a secret: node -e "console.log(require('crypto').randomBytes(256).toString('base64'));" |
The mongo host and port are not necessarily taken from the .env file they can be provided by the deployment environment such as k8s | |
| MONGO_HOST | mongo host |
| MONGO_PORT | mongo port |
| MONGO_DATABASE | name of the database |
| MONGO_USERNAME | mongo user - not used for development, required for production |
| MONGO_PASSWORD | mongo user's password - not used for development, required for production |
| Facebook credentials used for sign in with Facebook - currently not implemented | |
| FACEBOOK_ID | Facebook ID |
| FACEBOOK_SECRET | Facebook Secret |
Sendgrid credentials used by the nodemailer package in forgot/reset password functionality | |
| SENDGRID_USER | Sendgrid account user name |
| SENDGRID_PASSWORD | Sendgrid account password |
AWS user used for uploading files to s3 with AmazonS3FullAccess Policy | |
| AWS_ACCESS_KEY_ID | AWS Access key ID |
| AWS_ACCESS_KEY_SECRET | AWS Access key secret |
| This will be used to create a REGEX that will block origins that don't match | |
| CORS_REGEX | use localhost:\d{4}$ for development and domain\.tld$ for production |
The example in this project is built around the existence of a kubernetes cluster. You can easily change to your infrastructure of choice by changing the deploy step in .circleci/config.yml to pull the docker image wherever you need it.
# pull the image from docker hub and deploy it to the k8s cluster
deploy:
docker:
- image: feredean/circleci-kops:0.1.0
environment:
IMAGE_NAME: feredean/node-api-starter
KOPS_STATE_STORE: s3://k8s-explabs-io-state-store
steps:
- run:
name: Deploy to k8s cluster
command: |
# Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set in the project's env vars
kops export kubecfg --name k8s.explabs.io
kubectl set image deploy/node-api-starter node-api-starter=$IMAGE_NAME:$CIRCLE_SHA1
Depending on your cloud provider of choice you can fairly quickly set up a managed, production-ready environment for deploying containerized applications.
This project is deployed on a cluster set up with kops on aws spot instances. If there is interest I plan on going more in depth on this subject and provide a walk-through.
If you're like me and don't want the headache and uncertainty of managing your own production database take a look at mongodb's atlas. If you feel up to the task there are some kubernetes projects like KubeDB that can be of use.
First you need to have an .env.prod file that has all the secrets that will be used in production. A node-starter secret needs to be created, it is used by the API deployment.
kubectl create secret generic node-starter --from-env-file=.env.prod
Notice that in .kubernetes/deployment.yaml the environment is loaded from the node-starter secret
envFrom:
- secretRef:
name: node-starter
Finally you need to create the kubernetes deployment, service and optionally the horizontal pod autoscaler that can later be paired with the cluster autoscaler. To do this simply run the following:
kubectl create -f .kubernetes/deployment.yaml
If somehow a deadly bug has managed to make its way past the test suite and got deployed to production where it's wreaking havoc you need to run following command:
kubectl rollout undo deployment <your deployment name>
This will instantly roll back the deployment to the previous one.
To integrate with CircleCI:
Go to CircleCI and create an account
Link your project
Add the needed environment variables to run the test
# Used to connect to the kubernetes cluster
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
# Used for publishing the image
DOCKERHUB_PASS
DOCKERHUB_USERNAME
Make master branch a protected branch require ci/circleci: test check before merging from feature branches. Once a PR is merged into master CircleCI will automatically build, test and deploy the new version of the API.
Congratulations! You how have an API set up and ready to embrace the CD workflow!
| Name | Description |
|---|---|
| .circleci | Contains CircleCI settings for continuous deployment |
| .kubernetes | Contains kubernetes configuration for running the app |
Selected from shared topics, language and repository description—not editorial ratings.
electron-react-boilerplate /
A Foundation for Scalable Cross-Platform Apps
97/100 healththecodingmachine /
A React Native template for building solid applications 🐙, using JavaScript 💛 or Typescript 💙 (you choose).
94/100 healthobytes /
📱 A template for your next React Native project: Expo, PNPM, TypeScript, TailwindCSS, Husky, EAS, GitHub Actions, Env Vars, expo-router, react-query, react-hook-form.
93/100 healthpankod /
A well-structured production-ready frontend boilerplate with Typescript, React Testing Library, styled-component, React Query, .env, Axios, Bundle Analyzer, Prettier and 30+ plugins. superplate creates projects for React.js, Next.js, and refine. https://pankod.github.io/superplate/
78/100 healthreact-native-community /
👾 Clean and minimalist React Native template for a quick start with TypeScript.
88/100 healthAdrinlol /
Landy is an open-source React landing page template designed for developers and startups, who want to create a quick and professional landing page for their business or project.
92/100 health