{"id":13498604,"url":"https://github.com/serverless-components/backend","last_synced_at":"2025-03-29T01:32:11.240Z","repository":{"id":69341473,"uuid":"195483366","full_name":"serverless-components/backend","owner":"serverless-components","description":"Easily host entire web applications on a single AWS Lambda function using Serverless Components","archived":true,"fork":false,"pushed_at":"2020-02-06T11:55:23.000Z","size":74,"stargazers_count":16,"open_issues_count":6,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-14T18:37:10.054Z","etag":null,"topics":["aws","aws-lambda","serverless","serverless-components"],"latest_commit_sha":null,"homepage":"https://serverless.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless-components.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-06T01:11:21.000Z","updated_at":"2023-01-28T15:12:57.000Z","dependencies_parsed_at":"2024-01-18T23:04:50.834Z","dependency_job_id":"1f5fdc73-5b98-4f6d-ac83-a60f64258081","html_url":"https://github.com/serverless-components/backend","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless-components%2Fbackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless-components%2Fbackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless-components%2Fbackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless-components%2Fbackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless-components","download_url":"https://codeload.github.com/serverless-components/backend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222445082,"owners_count":16985755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","serverless","serverless-components"],"created_at":"2024-07-31T21:00:37.770Z","updated_at":"2024-10-31T16:30:24.056Z","avatar_url":"https://github.com/serverless-components.png","language":"JavaScript","readme":"# Backend\n\n\u0026nbsp;\n\nEasily host entire web applications on a single AWS Lambda function using this [Serverless Component](https://www.github.com/serverless/components).\n\n### Features\n\n- Designed to make it easy to host pre-existing web frameworks (e.g. Express.js, Hapi) or any large web application on a single AWS Lambda Function.\n- Blazing Fast Uploads via AWS S3 Accelerated Transfer and Multi-Part.\n- Dependencies are automatically put in AWS Lambda Layers, reducing cold-start time and further reducing upload time.\n- Simple shim for receiving and responding to HTTP requests.\n- Supports specifying custom domains.\n\n\u0026nbsp;\n\n1. [Install](#1-install)\n2. [Create](#2-create)\n3. [Configure](#3-configure)\n4. [Deploy](#4-deploy)\n\n\u0026nbsp;\n\n### 1. Install\n\n```console\n$ npm install -g serverless\n```\n\n### 2. Create\n\n```console\n$ mkdir backend \u0026\u0026 cd backend\n```\n\nThe directory should look something like this:\n\n```\n|- serverless.yml # required\n|- index.js       # required\n|- package.json   # optional\n|- .env           # your AWS api keys\n```\n\n```\n# .env\nAWS_ACCESS_KEY_ID=XXX\nAWS_SECRET_ACCESS_KEY=XXX\n```\n\nYou must include an `index.js` file that looks like this:\n\n```js\nmodule.exports = async (e, ctx, cb) =\u003e {\n  return { statusCode: 200, body: 'backend app deployed.' }\n}\n\n// you could also just return an object\n// which would return it as body with\n// 200 status code by default\n// module.exports = () =\u003e ({ hello: 'world' })\n\n// or just a string\n// module.exports = () =\u003e 'success'\n\n// or a status code number\n// module.exports = () =\u003e 404 // not found!\n\n// you don't even need to export a function!\n// module.exports = { hello: 'world' } // great for mocking!\n// module.exports = 'success'\n// module.exports = 500\n```\n\n### 3. Configure\n\nAll the following inputs are optional. However, they allow you to configure your Lambda compute instance and pass environment variables.\n\n```yml\n# serverless.yml\n\nbackend:\n  component: '@serverless/backend'\n  inputs:\n    code:\n      root: ./code # The root folder containing the backend code.\n      src: dist # The folder within your 'src' directory containing your built artifacts\n      hook: npm run build # A hook to build/test/do anything\n    region: us-east-1\n    runtime: nodejs10.x # The runtime for the lambda. Only nodejs10.x or nodejs8.10 are allowed\n    memory: 128\n    timeout: 10\n    description: A function for the registry backend.    \n    bucketName: myBucket # (Optional) The Bucket name where `src` files/folder will be upload.\n                         # If not provided, it will create random bucket name prefixed by `backend-`\n    env:\n      TABLE_NAME: my-table\n\n    # You can specify a custom domain name for your backend.\n    # You must have a public hosted zone available for this domain in AWS Route53.\n    # This is done automatically for you if you've purchased the domain via AWS Route53.\n    domain: api.example.com\n```\n\n### 4. Deploy\n\n```console\n$ serverless\n```\n\nAll requests to this root url will be proxied directly to your lambda function, giving you full control of the http layer.\n\n\u0026nbsp;\n\n### New to Components?\n\nCheckout the [Serverless Components](https://github.com/serverless/components) repo for more information.\n","funding_links":[],"categories":["组件","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless-components%2Fbackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless-components%2Fbackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless-components%2Fbackend/lists"}