npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

evari-quotes-api

v0.1.0

Published

Evari Quotes Microservice API

Downloads

1

Readme

Evari Quotes Microservice API

This is the API component of the Evari quotes microservice. It is built using the typescript-rest package and is based off the Evari Template API. Tests and swagger documentation are included.

Initial setup (VS Code)

Install the tslint and tsfmt extensions.

Add Evari NPM token to local env

Add export EVARI_NPM_TOKEN=[Value from mission critical doc] to bash profile.

Installing

Run npm install to install dependencies

Getting Started

Setting up Local Postgres Instance

  1. Install the legacy version of postgres from postgresapp.com that is closest to the 9.6.8 version that is supported by aurora.
  2. Run Postgres.app
  3. Open the side menu and remove any existing servers by clicking the "-" symbol on the bottom left
  4. Create a 9.6 server from the side menu, name "EvariPlatform", everything else leave as default.
  5. Click Initialize on the postgres app

Connecting to local postgres

  1. Install Postico from the website.
  2. Open Postico and setup a new favourite with the nickname "EvariPlatform" and everything else default
  3. Click EvariPlatform at the top left in the breadcrumbs to show all the current databases
  4. Create a new database called "evariplatform"
  5. Hit the red button to disconnect from the database
  6. Edit the favourite to change the Database to "evariplatform"
  7. Click EvariPlatform at the top left in the breadcrumbs to show all the current databases
  8. Delete the database that had been created by default with the name of the user on your machine (do not delete the db called postgres, template1 or evariplatform)

Creating a Database Table and Schema

  1. Define entitiy in db/entity
  2. Create your schema defined in the @Entity decorator of your new entities by running CREATE SCHEMA quote; within postico
  3. Run npm run db:migration:apply to run existing migrations
  4. Edit the existing entities or create new ones in the db/entity folder
  5. If you made an entity change, run npm run db:migration:generate -- -n descriptionOfFeature to create the migration eg. npm run db:migration:generate -- -n createWidgetTables or npm run db:migration:generate -- -n addNewLastUpdatedColumnToWidget
  6. npm run db:migration:apply to create the table

Run npm run build to generate type resources for request body validation.

Localstack

To run in test mode, all external dependencies will need to be hosted on your local machine via localstack

https://github.com/localstack/localstack

  1. Download and install the JDK - https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  2. pip install localstack --user localstack

  3. pip install amazon_kclpy // you need to do this because of a bug in localstack - might be fixed by the time you read this

  4. localstack start

  5. Create all the required AWS infrastructure in your localstack environment

    • aws --endpoint-url=http://localhost:4575 sns create-topic --name quotes-created
    • aws --endpoint-url=http://localhost:4575 sns create-topic --name quotes-updated
    • aws --endpoint-url=http://localhost:4576 sqs create-queue --queue-name evari-quotes-queue
    • aws --endpoint-url=http://localhost:4575 sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:123456789012:quotes-created --protocol sqs --notification-endpoint arn:aws:sns:ap-southeast-2:123456789012:evari-quotes-queue
    • aws --endpoint-url=http://localhost:4575 sns subscribe --topic-arn arn:aws:sns:ap-southeast-2:123456789012:quotes-updated --protocol sqs --notification-endpoint arn:aws:sns:ap-southeast-2:123456789012:evari-quotes-queue

NOTE! ALL SNS/SQS RESOURCES ARE LOST WHEN YOU STOP LOCALSTACK - A SOLUTION FOR THIS WILL HAVE TO BE DEVELOPED

Running in different evironments

npm start Will run the api with all possible external dependencies running locally via localstack. Particularly difficult to mock services will be created in the AWS Dev tennant

npm run start:stage Will run the api with all external dependencies running in the AWS Stage tennant (not recommended to run here as you may "steal" SNS/SQS messages that other people are relying on)

npm run start:prod Will run the api with all external dependencies running in the AWS Prod tennant (not recommended to run here as you may "steal" SNS/SQS messages that other people are relying on)

Running the tests

As part of the test script a prescript will run that will buld the project and run the linter. Failure on any of these and the tests will fail to run.

npm test

Deployment

TODO: configure circle ci

Versioning

Versioning will be controlled by the CI server. Any merges to master should be a patch version bump.

Database

npm scripts to manage migrations:

  • npm run db:migration:apply - will run all migration from src/db/migration dir always apply before you generate the migration script in case of Type ORM
  • npm run db:migration:generate -- -n [name] - - will generate a migration file named [timestamp]-[name].ts in src/db/migration dir
  • npm run db:migration:revert - will execute down in the latest executed migration. If you need to revert multiple migrations you must call this command multiple times.