@licoded/koa-puppeteer

1.0.6 • Public • Published

koa-puppeteer

A tool library based on koa and puppeteer, which can speed up your development.

Document

Click here for detailed documentation

Quick Start

Installation

PUPPETEER_DOWNLOAD_HOST=https://storage.googleapis.com.cnpmjs.org npm install --save @licoded/koa-puppeteer

PUPPETEER_DOWNLOAD_HOST=https://storage.googleapis.com.cnpmjs.org prefix is to speed up Chromium download in China.
If you are not in China, you may need to remove the prefix

Choose syntax to import

You can choose to use CommonJS syntax or ES Module syntax. Note that the default syntax of npm/nodejs project is CommonJS, if you want to use ES Module syntax, you need to add configuration "type": "module" in package.json. And when using ES Module syntax, the import path must be written in full.

CommonJS

const { MyKoa } = require('@licoded/koa-puppeteer');
const { createRouter } = require('@licoded/koa-puppeteer/lib/router');

ES Module

import { MyKoa } from '@licoded/koa-puppeteer';
import { createRouter } from '@licoded/koa-puppeteer/lib/router/index.js';

Code Example

const testRouter = createRouter('/test');

testRouter.get('/test', (ctx) => {
  ctx.body = 'hello';
});

new MyKoa({
  port: 3000,
  debug: false,
  launch: {
    userDataDir: '/Users/lic/dev/products/my-koa-cli/workspace',
  },
  routers: [testRouter],
}).run();

Readme

Keywords

none

Package Sidebar

Install

npm i @licoded/koa-puppeteer

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

12.3 kB

Total Files

20

Last publish

Collaborators

  • licoded