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

@eheikes/oscar-api

v0.1.0

Published

OSCAR assistant API

Downloads

2

Readme

OSCAR API Server

This project contains the API server for the OSCAR assistant. It is written for AWS Lambda and RDS.

Installation & Usage

  1. Create a Postgres DB in AWS RDS
    • Create the schemas defined in test/mocks/postgres.
  2. Create a serverless instance in AWS Lambda
    • Set the handler to index.handler.
    • Set the required environment variables under Configuration -> Environment variables. See .env.test for the list of variables and examples.
    • Set up an API gateway as the trigger.
  3. Download the AWS RDS certificate bundle for your region and replace the rds-ca-bundle.pem file in this api folder.
  4. Rename .env.example to .env and update it with your configuration, or set those variables in your environment.
    • Make sure NODE_ENV is not set to development.
  5. Run npm install && npm run build:release && ARN=YOUR_ARN npm run release.
    • Replace YOUR_ARN with the ARN of your Lambda instance.

API Reference

Coming soon

Development

Remember to set your environment variables (using .env or other method) to configure the app. Set a NODE_ENV environment variable to development for debugging.

Scripts for local development:

  • Run a local server: npm start.
  • Lint the files: npm run lint.
  • Build the app: npm run build. Run npm run build:release to minify the files.
  • Upload & publish to AWS Lambda: ARN=<LAMBDA ARN> npm run release
    • Replace <LAMBDA ARN> with your Lambda function's ARN.

For running automated tests:

  • To run all tests: npm run test. This needs to be set up for both unit and E2E tests as described below.
  • To run unit tests: npm run test:unit.
  • To run end-to-end tests:
    1. Start a local Postgres server. You can run a temporary server with Docker using something like docker run -v ./test/mocks/postgres:/docker-entrypoint-initdb.d -e POSTGRES_PASSWORD=test -d -p 5432:5432 postgres.
    2. Update .env.test to match the database credentials.
    3. Run npm run test:e2e.

Dev Troubleshooting

npm start crashes with uncaught exception

If you see:

node:internal/process/esm_loader:46
      internalBinding('errors').triggerUncaughtException(
                                ^
[Object: null prototype] {
  [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]]
}

It's probably a problem with the types. Run npm run build to see the error.

DB query isn't working

Add DEBUG=knex:query to your command to print out the Knex SQL queries.