{"_id":"@andrew-razumovsky/serverless-plugin-func-names","_rev":"1-6fd02d42aa95f3ca04af64bc0b9918c1","name":"@andrew-razumovsky/serverless-plugin-func-names","dist-tags":{"latest":"2.6.6"},"versions":{"2.6.6":{"name":"@andrew-razumovsky/serverless-plugin-func-names","publishConfig":{"access":"public"},"version":"2.6.6","description":"A serverless plugin for nextjs 8 serverless target","main":"index.js","keywords":["serverless","nextjs","lambda","next","api gateway"],"author":{"name":"Daniel Conde Marin","email":"danielconde9@gmail.com"},"license":"MIT","peerDependencies":{"next":"^9.0.0"},"repository":{"type":"git","url":"git+https://github.com/serverless-nextjs/serverless-next.js.git","directory":"packages/serverless-plugin"},"dependencies":{"@mapbox/s3urls":"^1.5.3","@sls-next/next-aws-lambda":"2.6.3","chalk":"^2.4.2","debug":"^4.1.1","fs-extra":"^7.0.1","js-yaml":"^3.12.1","klaw":"^3.0.0","lodash.clonedeep":"^4.5.0","lodash.merge":"^4.6.1","mime":"^2.4.0"},"engines":{"node":">=8.5.0"},"bugs":{"url":"https://github.com/serverless-nextjs/serverless-next.js/issues"},"homepage":"https://github.com/serverless-nextjs/serverless-next.js#readme","_id":"@andrew-razumovsky/serverless-plugin-func-names@2.6.6","_nodeVersion":"15.8.0","_npmVersion":"7.5.1","dist":{"integrity":"sha512-NNj8lFYsUGtFnOKF+wSApIXGw+e+yQu6yArDGiZOmcZTW2kfuk7a3aEmQb985ED8xHa9shdVuN1XV6Xu5AooBA==","shasum":"569a312e43a57aadfc3e839810549359767e50af","tarball":"https://registry.npmjs.org/@andrew-razumovsky/serverless-plugin-func-names/-/serverless-plugin-func-names-2.6.6.tgz","fileCount":39,"unpackedSize":2266231,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgdFpqCRA9TVsSAnZWagAAd0QP/j0OxCHKJIeFHYNTYSLI\nymf4RGw2c6FVFlQRYkrJGlAdF2qZ2bJehVSmfG1Iwcv1BFBJkbaFm6v6AMqS\nMLk6Xxsl4N6LGFfflQdm6t8nF/iKLk3Ih0gfYb/BUovgMLXKK//dINRkCb5U\nGUl5pRcuc9jjWGoz6FhuDP/qRZQSFR10mc07TaTSC5BsWtGy3kgcFXEGYb6h\nQ0cCRRA+Pe6LKmPt6Il0pZmawDR/SZ+GdryA7/438EUwZbdZESsQamGuSpBT\nCndJybQji2rykwLvZSZHU91n/JyKpZ1YnPjeafeJlV9gx7rGV5sOAeiqZpqG\nNHi6NJ4l6G8S3vyrU0X+rGJoThDKMhIiqeeGajTSWf0NNtBoArrtTBtbHCZh\nlZb9o7dZz8whj1eMuhsRO3dLdTzoSvn0cpc/s9QhKlQzPdb6nnIgEPqG0rbQ\nCFoE1RAAPZqBbgPN2SjycZt4XUR68vbMx0VSb68IydwehC0cWvW6qn6nV9op\ndyu+IDqPiKieS+oquLWfbk1GiqSIuPHjSQS1BPePDJmXwxZhgflYGKFhLEkl\nQsqsBJiTeGxSj2TsoD3BCH/NoN4FNaeSVzPkd09FPpKC6wtfS89O/MRqbiAG\n3o87kqXer2p0Mjvp2VPUHjilH8v75MzGPCNpSW5R24XURzVQ6QU1TatWwMPM\nNPIT\r\n=b3/X\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCB22O73Pfujn9s/2x0pW/HsN0jy9gLA0Yh92mQ5VJu/QIhAMG2cv83rxxADahLZycGJpXJ5JMkdLV4AzES30fYfIZz"}]},"_npmUser":{"name":"andrew-razumovsky","email":"grimones00@gmail.com"},"directories":{},"maintainers":[{"name":"andrew-razumovsky","email":"grimones00@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/serverless-plugin-func-names_2.6.6_1618238057455_0.6541851118788129"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-12T14:34:17.389Z","2.6.6":"2021-04-12T14:34:17.693Z","modified":"2022-04-04T14:01:02.863Z"},"maintainers":[{"name":"andrew-razumovsky","email":"grimones00@gmail.com"}],"description":"A serverless plugin for nextjs 8 serverless target","homepage":"https://github.com/serverless-nextjs/serverless-next.js#readme","keywords":["serverless","nextjs","lambda","next","api gateway"],"repository":{"type":"git","url":"git+https://github.com/serverless-nextjs/serverless-next.js.git","directory":"packages/serverless-plugin"},"author":{"name":"Daniel Conde Marin","email":"danielconde9@gmail.com"},"bugs":{"url":"https://github.com/serverless-nextjs/serverless-next.js/issues"},"license":"MIT","readme":"# UPDATE!\n\nA new iteration of this project has been released powered by the amazing [Serverless Components](https://github.com/serverless/components).\nCheck it out [here](https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/serverless-components/nextjs-component). As you can see, it lives in the same monorepo.\nThe new version has feature parity with nextjs 9.0 and does not use CloudFormation, allowing faster deployments and no [resource limit issues](https://github.com/serverless-nextjs/serverless-next.js/issues/17).\n\nIt is recommended for both existing and new users to try the new version. Obviously existing users of the next plugin don't have to migrate over straight away, the plan is to continue maintaining the plugin until the new component is more mature.\n\n# Serverless Nextjs Plugin\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![Build Status](https://travis-ci.org/danielcondemarin/serverless-next.js.svg?branch=master)](https://travis-ci.org/danielcondemarin/serverless-nextjs-plugin)\n[![Financial Contributors on Open Collective](https://opencollective.com/serverless-nextjs-plugin/all/badge.svg?label=financial+contributors)](https://opencollective.com/serverless-nextjs-plugin) [![npm version](https://badge.fury.io/js/serverless-nextjs-plugin.svg)](https://badge.fury.io/js/serverless-nextjs-plugin)\n[![Coverage Status](https://coveralls.io/repos/github/danielcondemarin/serverless-next.js/badge.svg?branch=master)](https://coveralls.io/github/danielcondemarin/serverless-nextjs-plugin?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c0d3aa2a86cb4ce98772a02015f46314)](https://www.codacy.com/app/danielcondemarin/serverless-nextjs-plugin?utm_source=github.com&utm_medium=referral&utm_content=danielcondemarin/serverless-nextjs-plugin&utm_campaign=Badge_Grade)\n\nA [serverless framework](https://serverless.com/) plugin to deploy nextjs apps.\n\nThe plugin targets [Next 8 serverless mode](https://nextjs.org/blog/next-8/#serverless-nextjs)\n\n![demo](./demo.gif)\n\n## Contents\n\n- [Motivation](#motivation)\n- [Getting Started](#getting-started)\n- [Hosting static assets](#hosting-static-assets)\n- [Serving static assets](#serving-static-assets)\n- [Deploying](#deploying)\n- [Overriding page configuration](#overriding-page-configuration)\n- [Custom page routing](#custom-page-routing)\n- [Custom error page](#custom-error-page)\n- [Custom lambda handler](#custom-lambda-handler)\n- [All plugin configuration options](#all-plugin-configuration-options)\n- [Examples](#examples)\n- [Caveats](#caveats)\n- [Contributing](#contributing)\n\n## Motivation\n\nNext 8 released [official support](https://nextjs.org/blog/next-8/#serverless-nextjs) for serverless! It doesn't work out of the box with AWS Lambdas, instead, next provides a low level API which this plugin uses to deploy the serverless pages.\n\nNextjs serverless page handler signature:\n\n```js\nexports.render = function(req, res) => {...}\n```\n\nAWS Lambda handler:\n\n```js\nexports.handler = function(event, context, callback) {...}\n```\n\nA compat layer between the nextjs page bundles and AWS Lambda is added at build time:\n\n```js\nconst compat = require(\"@sls-next/next-aws-lambda\");\nconst page = require(\".next/serverless/pages/somePage.js\");\n\nmodule.exports.render = (event, context, callback) => {\n  compat(page)(event, context, callback);\n};\n```\n\n## Getting started\n\n### Installing\n\n`npm install --save-dev @sls-next/serverless-plugin`\n\nOut of the box, the plugin won't require any configuration. If you need to override any defaults check [this](#all-plugin-configuration-options).\n\nFor example:\n\n```\nnextApp\n│   next.config.js\n│   serverless.yml\n└───pages\n│   │   home.js\n│   │   about.js\n│   │   admin.js\n```\n\nEdit the serverless.yml and add:\n\n```yml\nplugins:\n  - serverless-nextjs-plugin\n\npackage:\n  exclude:\n    - ./**\n```\n\nYou can exclude everything. The plugin makes sure the page handlers are included in the artifacts.\n\n## Hosting static assets\n\nIf you don't want to manage uploading the next static assets yourself, like uploading them to a CDN, the plugin can do this for you by hosting the asset files on S3.\n\nThe easiest way is to use a [valid bucket URL](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro) in the `assetPrefix` field of your next configuration:\n\n```js\n// next.config.js\nmodule.exports = {\n  assetPrefix: \"https://s3.amazonaws.com/your-bucket-name\"\n};\n```\n\nThe plugin will create a new S3 Bucket using the parsed name. On deployment, static assets will be uploaded to the bucket provisioned.\n\nAlternatively, if you just want the assets to get uploaded to S3, you can provide the bucket name via the plugin config:\n\n```yml\n# serverless.yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    assetsBucketName: \"your-bucket-name\"\n```\n\n## Serving static assets\n\nStatic files can be served by [following the NextJs convention](https://github.com/zeit/next.js/#static-file-serving-eg-images) of using a `static` and `public` folder.\n\nFrom your code you can then reference those files with a `/static` URL:\n\n```\nfunction MyImage() {\n  return <img src=\"/static/my-image.png\" alt=\"my image\" />\n}\n\nexport default MyImage\n```\n\nTo serve static files from the root directory you can add a folder called public and reference those files from the root, e.g: /robots.txt.\n\nNote that for this to work, an S3 bucket needs to be provisioned as per [hosting-static-assets](#hosting-static-assets).\n\n**For production deployments, enabling CloudFront is recommended:**\n\n```yml\n# serverless.yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    assetsBucketName: \"your-bucket-name\"\n    cloudFront: true\n```\n\nBy doing this, a CloudFront distribution will be created in front of your next application to serve any static assets from S3 and the pages from Api Gateway.\n\nNote that deploying the stack for the first time will take considerably longer, as CloudFront takes time propagating the changes, typically 10 - 20mins.\n\nYou can provide your own configuration for the CloudFront distribution:\n\n```yml\n# serverless.yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    assetsBucketName: \"your-bucket-name\"\n    cloudFront: ${file(cloudfront-override.yml)}\n```\n\n```yml\n# cloudfront-override.yml\n# e.g. add custom domain name\nProperties:\n  DistributionConfig:\n    Aliases:\n      - my.alias.com\n    ViewerCertificate:\n      AcmCertificateArn: arn:aws:acm:xxxx\n      ...\n```\n\nThe configuration provided will be merged onto the defaults in `packages/serverless-plugin/resources/cloudfront.yml`.\n\n## Deploying\n\n`serverless deploy`\n\nWhen running `serverless deploy` all your next pages will be automatically compiled, packaged and deployed.\n\nThe Lambda functions created for each page have by default the following configuration:\n\n```yml\nhandler: /path/to/page/handler.render\nevents:\n  - http:\n      path: pageName # home, about, etc. Unless is the index page which is served at /\n      method: get\n  - http:\n      path: pageName # home, about, etc. Unless is the index page which is served at /\n      method: head\n```\n\n## Overriding page configuration\n\nYou may want to have a different configuration for one or more of your page functions. This is possible by setting the `pageConfig` key in the plugin config:\n\n```yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    pageConfig:\n      about:\n        memorySize: 512 # default is 1024\n      home:\n        timeout: 10 # default is 6\n```\n\nIf you need to change the default configuration, such as `memorySize`, `timeout` etc. use the top level `provider` which will override all the functions configuration. For example, to change the memorySize to 512MB:\n\n```yml\nprovider:\n  name: aws\n  runtime: nodejs8.10\n  memorySize: 512\n  ...\n```\n\nYou can also add configuration for all page functions by adding an asterisk entry (`*`) to `pageConfig`. This is particularly useful when you have other functions in your service (i.e. an `api`) aside from the page functions and you only want to apply configuration changes to the latter:\n\n```yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    pageConfig:\n      \"*\":\n        layers:\n          - arn:aws:lambda:${self:provider.region}:553035198032:layer:nodejs12:1\n```\n\nYou can set any function property described [here](https://serverless.com/framework/docs/providers/aws/guide/functions#configuration).\n\n## Custom page routing\n\nThe default page routes follow the same convention as next `useFileSystemPublicRoutes` documented [here](https://nextjs.org/docs/#routing).\n\nE.g.\n\n| page                        | path                |\n| --------------------------- | ------------------- |\n| pages/index.js              | /                   |\n| pages/post.js               | /post               |\n| pages/blog/index.js         | /blog               |\n| pages/categories/uno/dos.js | /categories/uno/dos |\n\nYou may want to serve your page from a different path. This is possible by setting your own http path in the `routes` config. For example for `pages/post.js`:\n\n```js\nclass Post extends React.Component {\n  static async getInitialProps({ query }) {\n    return {\n      slug: query.slug\n    };\n  }\n  render() {\n    return <h1>Post page: {this.props.slug}</h1>;\n  }\n}\n\nexport default Post;\n```\n\n```yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    routes:\n      - src: post\n        path: posts/{slug}\n        request:\n          parameters:\n            paths:\n              slug: true\n```\n\n## Custom error page\n\n404 or 500 errors are handled both client and server side by a default component `error.js`, same as documented [here](https://github.com/zeit/next.js/#custom-error-handling).\n\nSimply add `pages/_error.js`:\n\n```js\nclass Error extends React.Component {\n  static getInitialProps({ res, err }) {\n    const statusCode = res ? res.statusCode : err ? err.statusCode : null;\n    return { statusCode };\n  }\n\n  render() {\n    return (\n      <p>\n        {this.props.statusCode\n          ? `An error ${this.props.statusCode} occurred on server (╯°□°)╯︵ ┻━┻`\n          : \"An error occurred on client\"}\n      </p>\n    );\n  }\n}\n\nexport default Error;\n```\n\n## Custom lambda handler\n\nIf you need to customize the lambda handler you can do so by providing a path to your own handler in the `customHandler` field. Note that it resolves the path to the custom handler relative to your `next.config.js`.\n\n```yml\nplugins:\n  - serverless-nextjs-plugin\n\ncustom:\n  serverless-nextjs:\n    customHandler: ./handler.js\n```\n\nThe custom handler needs to look something like this:\n\n```js\nconst compat = require(\"@sls-next/next-aws-lambda\");\n\nmodule.exports = (page) => {\n  const handler = (event, context) => {\n    // do any stuff you like\n\n    // this makes sure the next page renders\n    const responsePromise = compat(page)(event, context);\n\n    // do any other stuff you like\n\n    return responsePromise;\n  };\n  return handler;\n};\n```\n\n## All plugin configuration options\n\n| Plugin config key | Type               | Default Value | Description                                                                                                                                                                                                                   |\n| ----------------- | ------------------ | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| nextConfigDir     | `string`           | ./            | Path to parent directory of `next.config.js`.                                                                                                                                                                                 |\n| assetsBucketName  | `string`           | \\<empty\\>     | Creates an S3 bucket with the name provided. The bucket will be used for uploading next static assets.                                                                                                                        |\n| cloudFront        | `bool` \\| `object` | false         | Set to `true` to create a cloud front distribution in front of your nextjs application. Also can be set to an `object` if you need to override CloudFront configuration, see [serving static assets](#serving-static-assets). |\n| routes            | `[]object`         | []            | Array of custom routes for the next pages.                                                                                                                                                                                    |\n| customHandler     | `string`           | \\<empty\\>     | Path to your own lambda handler.                                                                                                                                                                                              |\n| uploadBuildAssets | `bool`             | true          | In the unlikely event that you only want to upload `static` or `public` dirs, set this to `false`.                                                                                                                            |\n| createAssetBucket | `bool`             | true          | Set to false if you want to manage next assets yourself.                                                                                                                                                                      |\n\n## Caveats\n\nBeware this plugin relies on CloudFormation which has a hard limit of 200 resources. If you have a large number of pages in your application it is very likely that you will hit this limit. Use https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/serverless-components/nextjs-component which solves this problem by not using CloudFormation.\n\n## Examples\n\nSee the `examples/` directory.\n\n## Contributing\n\nPlease see the [contributing](./CONTRIBUTING.md) guide.\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n<a href=\"https://github.com/serverless-nextjs/serverless-next.js/tree/master/packages/deprecated/serverless-plugin/graphs/contributors\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/contributors.svg?width=890&button=false\" /></a>\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/serverless-nextjs-plugin/contribute)]\n\n#### Individuals\n\n<a href=\"https://opencollective.com/serverless-nextjs-plugin\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/individuals.svg?width=890\"></a>\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/serverless-nextjs-plugin/contribute)]\n\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/0/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/0/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/1/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/1/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/2/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/2/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/3/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/3/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/4/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/4/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/5/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/5/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/6/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/6/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/7/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/7/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/8/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/8/avatar.svg\"></a>\n<a href=\"https://opencollective.com/serverless-nextjs-plugin/organization/9/website\"><img src=\"https://opencollective.com/serverless-nextjs-plugin/organization/9/avatar.svg\"></a>\n","readmeFilename":"README.md"}