Skip to content

Commit

Permalink
attempt to update devDependencies to latest versions #104
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Feb 8, 2023
1 parent 207bf42 commit 3e90c01
Show file tree
Hide file tree
Showing 11 changed files with 8,232 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fly.toml
Dockerfile
.dockerignore
node_modules
.git
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ node_modules
# Users Environment Variables
.lock-wscript
example/lib/db
package-lock.json
1 change: 1 addition & 0 deletions .nyc_output/5af5752a-8fef-46d9-9174-1acf5f51b9f8.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"parent":null,"pid":23804,"argv":["/usr/local/bin/node","/Users/n/code/learn-json-web-tokens/node_modules/.bin/tape","./example/test/functional.js"],"execArgv":[],"cwd":"/Users/n/code/learn-json-web-tokens","time":1675864649664,"ppid":23801,"coverageFilename":"/Users/n/code/learn-json-web-tokens/.nyc_output/5af5752a-8fef-46d9-9174-1acf5f51b9f8.json","externalId":"","uuid":"5af5752a-8fef-46d9-9174-1acf5f51b9f8","files":["/Users/n/code/learn-json-web-tokens/example/test/functional.js","/Users/n/code/learn-json-web-tokens/example/lib/helpers.js","/Users/n/code/learn-json-web-tokens/example/test/mock.js"]}
1 change: 1 addition & 0 deletions .nyc_output/processinfo/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"processes":{"5af5752a-8fef-46d9-9174-1acf5f51b9f8":{"parent":null,"children":[]}},"files":{"/Users/n/code/learn-json-web-tokens/example/test/functional.js":["5af5752a-8fef-46d9-9174-1acf5f51b9f8"],"/Users/n/code/learn-json-web-tokens/example/lib/helpers.js":["5af5752a-8fef-46d9-9174-1acf5f51b9f8"],"/Users/n/code/learn-json-web-tokens/example/test/mock.js":["5af5752a-8fef-46d9-9174-1acf5f51b9f8"]},"externalIds":{}}
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM debian:bullseye as builder

ARG NODE_VERSION=18.12.1

RUN apt-get update; apt install -y curl python-is-python3 pkg-config build-essential
RUN curl https://get.volta.sh | bash
ENV VOLTA_HOME /root/.volta
ENV PATH /root/.volta/bin:$PATH
RUN volta install node@${NODE_VERSION}

#######################################################################

RUN mkdir /app
WORKDIR /app

# NPM will not install any package listed in "devDependencies" when NODE_ENV is set to "production",
# to install all modules: "npm install --production=false".
# Ref: https://docs.npmjs.com/cli/v9/commands/npm-install#description

ENV NODE_ENV production

COPY . .

RUN npm install
FROM debian:bullseye

LABEL fly_launch_runtime="nodejs"

COPY --from=builder /root/.volta /root/.volta
COPY --from=builder /app /app

WORKDIR /app
ENV NODE_ENV production
ENV PATH /root/.volta/bin:$PATH

CMD [ "npm", "run", "start" ]
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<div align="ceter"
>
![JWT logo wider](https://i.imgur.com/qDOOu4o.jpg)

# Learn how to use *JSON Web Tokens* (JWT) for *Authentication*
# Learn how to use *JSON Web Tokens* (JWT) for *Auth*.

![dilbert fixed the internet](https://i.imgur.com/cNElVof.jpg)

Learn how to use JSON Web Token (JWT) to *secure* your Web and/or Mobile Application!

[![Build Status](https://img.shields.io/travis/dwyl/learn-json-web-tokens/master.svg?style=flat-square)](https://travis-ci.org/dwyl/learn-json-web-tokens)
[![codecov.io](https://img.shields.io/codecov/c/github/dwyl/learn-json-web-tokens/master.svg?style=flat-square)](https://codecov.io/github/dwyl/learn-json-web-tokens?branch=master)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/dwyl/learn-json-web-tokens/Node.js%20CI?style=flat-square)](https://github.com/dwyl/learn-json-web-tokens/actions)
[![codecov.io](https://img.shields.io/codecov/c/github/dwyl/learn-json-web-tokens/master.svg?style=flat-square)](https://codecov.io/github/dwyl/learn-json-web-tokens?branch=main)
[![codeclimate-maintainability](https://img.shields.io/codeclimate/maintainability/dwyl/learn-json-web-tokens.svg?style=flat-square)](https://codeclimate.com/github/dwyl/learn-json-web-tokens/maintainability)
[![Dependencies Status](https://david-dm.org/dwyl/learn-json-web-tokens/status.svg?style=flat-square)](https://david-dm.org/dwyl/learn-json-web-tokens)
[![devDependencies Status](https://david-dm.org/dwyl/learn-json-web-tokens/dev-status.svg?style=flat-square)](https://david-dm.org/dwyl/learn-json-web-tokens?type=dev)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/dwyl/learn-json-web-tokens/issues)
[![HitCount](https://hits.dwyl.com/dwyl/learn-json-web-tokens.svg)](https://hits.dwyl.io/dwyl/learn-json-web-tokens)

</div>


## *Why*?

Expand Down Expand Up @@ -81,8 +83,8 @@ Claims are the predefined **keys** and their **values**:
+ **iss**: issuer of the token
+ **exp**: the expiration timestamp (reject tokens which have expired). Note: as defined in the spec, this must be in seconds.
+ **iat**: The time the JWT was issued. Can be used to determine the age of the JWT
+ **nbf**: "not before" is a future time when the token will become active.
+ **jti**: unique identifier for the JWT. Used to prevent the JWT from being re-used or replayed.
+ **nbf**: "not before" is a future time when the token will become active. (optional)
+ **sub**: subject of the token (rarely used)
+ **aud**: audience of the token (also rarely used)

Expand Down Expand Up @@ -162,9 +164,9 @@ its pretty safe to compute them synchronously.

> Tip: If you're looking for a ***Full Featured*** **JWT Auth Hapi.js plugin** (which does the verification/validation *asynchronously*) for your Hapi.js-based app please check out: [https://github.com/**dwyl/hapi-auth-jwt2**](https://github.com/dwyl/hapi-auth-jwt2)
## Tests
## Tests

You may have noticed the [![Build Status][travis-image]][travis-url] badge at the *start* of this tutorial.
You may have noticed the [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/dwyl/learn-json-web-tokens/Node.js%20CI?style=flat-square)](https://github.com/dwyl/learn-json-web-tokens/actions) badge at the *start* of this tutorial.
This is a sign the author(s) are not just *cobbling* code together.
The tests for both the server routes and helper functions are in: **/example/test**

Expand Down
14 changes: 7 additions & 7 deletions example/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var port = process.env.PORT || 1337; // let heroku define port or use 1337
var http = require('http'); // core node.js http (no frameworks)
var url = require('url'); // core node.js url (no frameworks)
var app = require('./lib/helpers'); // auth, token verification & render helpers
var c = function(res){ /* */ };
const port = process.env.PORT || 1337; // let heroku define port or use 1337
const http = require('http'); // core node.js http (no frameworks)
const url = require('url'); // core node.js url (no frameworks)
const app = require('./lib/helpers'); // auth, token verification & render helpers
const c = function(res){ /* */ };

http.createServer(function (req, res) {
var path = url.parse(req.url).pathname;
const path = url.parse(req.url).pathname;
if( path === '/' || path === '/home' ) { app.home(res); } // homepage
else if( path === '/auth') { app.handler(req, res); } // authenticator
else if( path === '/private') { app.validate(req, res, app.done); } // private content
Expand All @@ -14,4 +14,4 @@ http.createServer(function (req, res) {
else { app.notFound(res); } // 404 error
}).listen(port);

console.log("Visit: http://127.0.0.1:" + port);
console.info("Visit: http://127.0.0.1:" + port);
37 changes: 37 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# fly.toml file generated for learn-jwt on 2023-02-08T13:49:12Z

app = "learn-jwt"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
auto_rollback = true

[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
force_https = true
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
Loading

0 comments on commit 3e90c01

Please sign in to comment.