Skip to content

Commit

Permalink
Migrated to Vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed May 11, 2020
1 parent e74bcb8 commit cccd5a5
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 31 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# zeit-now-node-server
# vercel-node-server

An unofficial package allowing you to create Node [`http.Server`](https://nodejs.org/api/http.html#http_class_http_server) instances of your [Zeit](https://zeit.co/) [`@now/node`](https://zeit.co/docs/builders#official-builders/node-js) lambdas.
An unofficial package allowing you to create Node [`http.Server`](https://nodejs.org/api/http.html#http_class_http_server) instances of your [Vercel](https://vercel.com/) [Node](https://vercel.com/docs/runtimes#official-runtimes) lambdas.

Enables you to write unit/integration tests for your lambdas, or to perform manual testing against a local server instance.

[![npm](https://img.shields.io/npm/v/zeit-now-node-server.svg?style=flat-square)](http://npm.im/zeit-now-node-server)
[![MIT License](https://img.shields.io/npm/l/zeit-now-node-server.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![Travis](https://img.shields.io/travis/ctrlplusb/zeit-now-node-server.svg?style=flat-square)](https://travis-ci.org/ctrlplusb/zeit-now-node-server)
[![Codecov](https://img.shields.io/codecov/c/github/ctrlplusb/zeit-now-node-server.svg?style=flat-square)](https://codecov.io/github/ctrlplusb/zeit-now-node-server)
[![npm](https://img.shields.io/npm/v/vercel-node-server.svg?style=flat-square)](http://npm.im/vercel-node-server)
[![MIT License](https://img.shields.io/npm/l/vercel-node-server.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![Travis](https://img.shields.io/travis/ctrlplusb/vercel-node-server.svg?style=flat-square)](https://travis-ci.org/ctrlplusb/vercel-node-server)
[![Codecov](https://img.shields.io/codecov/c/github/ctrlplusb/vercel-node-server.svg?style=flat-square)](https://codecov.io/github/ctrlplusb/vercel-node-server)

## Installation

```bash
npm install zeit-now-node-server
npm install vercel-node-server
```

## Supported API

This package has taken the code from the official [`@now/node`](https://zeit.co/docs/builders#official-builders/node-js) builder in order to ensure maximum API compatibility. As far as I am aware we have 100% API coverage.
This package has taken the code from the official [`@vercel/node`](https://vercel.com/docs/runtimes#official-runtimes) builder in order to ensure maximum API compatibility. As far as I am aware we have 100% API coverage.

## Unit testing your lambdas

Expand All @@ -28,15 +28,15 @@ We will be making use of the [`test-listen`](https://github.com/zeit/test-listen
We will also make use of [`axios`](https://github.com/axios/axios) in order to make the request against our lambda.

```javascript
import { createServer } from 'zeit-now-node-server';
import { createServer } from 'vercel-node-server';
import listen from 'test-listen';
import axios from 'axios';
import helloLambda from './api/hello';

let server;
let url;

beforeAll(() => {
beforeAll(async () => {
server = createServer(routeUnderTest);
url = await listen(server);
});
Expand All @@ -45,7 +45,7 @@ afterAll(() => {
server.close();
});

it('should return the expected response' async () => {
it('should return the expected response', async () => {
const response = await axios.get(url, { params: { name: 'Pearl' } });
expect(response.data).toBe('Hello Pearl');
});
Expand All @@ -64,7 +64,7 @@ const helloLambda = (req, res) => {
You can create a Node [`http.Server`](https://nodejs.org/api/http.html#http_class_http_server) instance like so.

```javascript
import { createServer } from 'zeit-node-now-server';
import { createServer } from 'vercel-node-server';
import helloLambda from './api/hello';

const server = createServer(helloLambda);
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ const path = require('path');
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/test/**/*.test.ts'],
};
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "zeit-now-node-server",
"version": "1.0.1",
"description": "Create a server for your Zeit @now/node lambdas in order to test them",
"name": "vercel-node-server",
"version": "2.0.0",
"description": "Create a server for your Vercel Node lambdas in order to test them",
"license": "MIT",
"author": "Sean Matheson",
"main": "dist/index.js",
"module": "dist/zeit-now-node-server.esm.js",
"module": "dist/vercel-node-server.esm.js",
"typings": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/ctrlplusb/zeit-now-node-server.git"
"url": "https://github.com/ctrlplusb/vercel-node-server.git"
},
"files": [
"dist"
Expand All @@ -36,7 +36,6 @@
"trailingComma": "es5"
},
"devDependencies": {
"@now/node": "^1.0.2",
"@types/content-type": "^1.1.3",
"@types/cookie": "^0.3.3",
"@types/jest": "^25.2.1",
Expand All @@ -54,6 +53,7 @@
"typescript": "^3.8.3"
},
"dependencies": {
"@vercel/node": "^1.6.1",
"content-type": "^1.0.4",
"cookie": "^0.4.1",
"micro": "^9.3.4",
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NowRequest, NowResponse } from '@now/node';
import { NowRequest, NowResponse } from '@vercel/node';
import { Server } from 'http';
import axios from 'axios';
import fs from 'fs';
import path from 'path';
import listen from 'test-listen';
import { createServer } from '../src';
import { createServer } from '../';

let server: Server;
let url: string;
Expand Down Expand Up @@ -137,7 +137,7 @@ it('body - json', async () => {
});

describe('request handling', () => {
it.only('body - invalid json', async () => {
it('body - invalid json', async () => {
// ARRANGE
route = () => {};

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
NowRequestBody,
NowRequest,
NowResponse,
} from '@now/node';
} from '@vercel/node';
import { IncomingMessage, ServerResponse } from 'http';
import { parse } from 'cookie';
import { parse as parseContentType } from 'content-type';
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["src", "types", "test"],
"include": ["src", "types", "src/test"],
"compilerOptions": {
"target": "es5",
"module": "esnext",
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1312,13 +1312,6 @@
"@types/yargs" "^15.0.0"
chalk "^3.0.0"

"@now/node@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@now/node/-/node-1.0.2.tgz#484e595d992d52728f5b6e82c0310b5a7ceba851"
integrity sha512-jGcpqOyQuxbYz0yBAV+Y5VTmuCF+geai1zOQPPKBNzsh+9j5Yoo8f0ImaGYkJeTQv19exKf3hHa5OcA4q4+5qg==
dependencies:
"@types/node" "*"

"@rollup/plugin-commonjs@^11.0.0":
version "11.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-11.1.0.tgz#60636c7a722f54b41e419e1709df05c7234557ef"
Expand Down Expand Up @@ -1603,6 +1596,13 @@
semver "^6.3.0"
tsutils "^3.17.1"

"@vercel/node@^1.6.1":
version "1.6.1"
resolved "https://registry.yarnpkg.com/@vercel/node/-/node-1.6.1.tgz#03b08cb88a2ea82bb80603e81ae61e7e283ace5a"
integrity sha512-sCxhMtShD2kCcpznmYO5HaCG3LaqaJVm0xZiJq8BuGIuSNWgS/aXi5IESFa01whsafaS7WhdMTlAwNPPOvH5lg==
dependencies:
"@types/node" "*"

abab@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.2.tgz#a2fba1b122c69a85caa02d10f9270c7219709a9d"
Expand Down

0 comments on commit cccd5a5

Please sign in to comment.