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

@layerframers/whereami

v1.2.6

Published

Tools that help with fetching location based info when building production SSR apps, e.g. NextJS. Client vs. Server, Staging vs. Production, etc.

Downloads

37

Readme

Where Am I?

Tools that help with fetching location based info when building production SSR apps, e.g. NextJS. Client vs. Server, Staging vs. Production, etc.

Getting started

  1. yarn add @layerframers/whereami
  2. Set a staging url by creating an env var named STAGING_URL or STAGE_URL
  3. Set a production url by creating an env var named PRODUCTION_URL or LIVE_URL
  4. Set a development url by creating an env var named DEVELOP_URL or DEVELOPMENT_URL
  5. In your script use the following
import whereami from '@layerframers/whereami'
...
// This is checks to see if you're on, staging, production or local and on the client or server side.
const host = whereami.now()

Google App Engine Features

This node modules plays well with Google App Engine. To check for a staging environment running on Google App Engine, just set the following environment variables in you app.yaml.

By setting WHEREAMI_GCP_CHECK to true, you turn on GCP checking. You then need to set the staging key. This is basically an indicator or difference in the name e.g. -staging. This value is checked against the Google Cloud environment variable named GOOGLE_CLOUD_PROJECT via the indexOf method of Javascript.

WHEREAMI_GCP_CHECK: {bool} true/false (Defaults to false)
WHEREAMI_GCP_STAGE_KEY {string} '-staging' (Defaults to -staging)
WHEREAMI_GCP_DEVELOP_KEY {string} '-develop' (Defaults to -develop)

Usage

  • whereami.now(): Returns the hostname
  • whereami.log(): Prints out helpful log info
  • whereami.isStaging: Tells you if you're on your staging server or not
  • whereami.isProduction: Tells you if you're on your production server or not
  • whereami.isDev: Tells you if you're on your development server or not
  • whereami.isLocal: Tells you if you're on your local server or not
  • whereami.isServer: Tells you if you're on the server or not
  • whereami.isClient: Tells you if you're on the client/browser or not