{"id":328886,"date":"2022-01-31T21:01:05","date_gmt":"2022-01-31T21:01:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328886"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328886","title":{"rendered":"<span>Simple serverless front + back<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u043d\u0430\u0440\u0435\u0437\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e frontend \u0438 backend.\u00a0<\/p>\n<p>AWS S3 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 S3 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"223\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/793\/299\/13b\/79329913b37b3b3f585d08d9a4415441.png\" data-width=\"365\"\/><figcaption><\/figcaption><\/figure>\n<p>\u042f \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c Frontend, Backend, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0440\u0435\u0437\u043a\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/648519\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e<\/a>, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"654\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cd5\/2d4\/a01\/cd52d4a01a3d698aa0f98392e25054e6.png\" data-width=\"821\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 backend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a:<\/p>\n<pre><code class=\"javascript\">const {S3Client, PutObjectCommand} = require('@aws-sdk\/client-s3'); const {v4} = require(\"uuid\");  const s3 = new S3Client({     signatureVersion: 'v4',     region: config.REGION });  const S3PutObjectCommand = (Key) => {     return new PutObjectCommand({         ACL: 'public-read',         Bucket: config.S3_BUCKET,         Key,     }); } const getS3SignedUrl = (name) => {     const command = S3PutObjectCommand(name)     return getSignedUrl(s3, command, {expiresIn: 600}) } const getFileName = (key) => `${key}.jpg`;  const generateFileKey = () => {     return v4() }  module.exports.handler = async () => {     const key = generateFileKey()     const fileName = getFileName(key)     const url = await getS3SignedUrl(fileName);     return {         statusCode: 200,       \/\/ \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0434\u043b\u044f CORS.          \/\/ \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a,          \/\/ \u0447\u0442\u043e\u0431 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432         headers: {             'Content-Type': 'application\/json',             'Access-Control-Allow-Origin': '*',             'Access-Control-Allow-Credentials': true,         },         body: JSON.stringify({key, url, fileName})     }; }<\/code><\/pre>\n<p>\u041e\u0431\u0435\u0440\u043d\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 Lambda \u0438 ApiGateway \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Serverless Framework.\u00a0<\/p>\n<pre><code class=\"yaml\">service: service-simple-serverless-back frameworkVersion: '2 || 3' app: simple-serverless-back  package:   patterns:     - '!node_modules\/aws-sdk'     - '!node_modules\/serverless'     - '!node_modules\/@serverless'     - '!.idea'     - '!images'     - '!yarn.lock'     - '!yarn.error.log'     - '!README.md'     - '!.gitignore'     - '!package.json'     - '!.git'  custom:   name: 'simple-serverless-back'   environment: 'prod'   region: 'us-east-1'   # \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u043a\u0435\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b,    # \u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f   bucket: 'service-lambda-thumb-tifig-d-sourcebucketdc914398-10oo755kbh9e8'   lambda_prefix: ${self:custom.environment}-${self:custom.name}  provider:   name: aws   lambdaHashingVersion: '20201221'   environment:     S3_BUCKET: ${self:custom.bucket}     REGION: ${self:custom.region}   region: ${self:custom.region}   runtime: nodejs14.x   iamRoleStatements:     - Effect: Allow       Action:         - s3:PutObject         - s3:PutObjectAcl         - s3:GetObject       Resource:         - 'arn:aws:s3:::${self:custom.bucket}'         - 'arn:aws:s3:::${self:custom.bucket}\/*'  functions:   getS3SignedUrl:     name: get-s3-signed-url     handler: index.handler     events:       - http:           method: GET           path: \/           cors: true <\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c <code>sls deploy<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043b\u044f\u043c\u0431\u0434\u0443:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"822\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6af\/bc9\/d7e\/6afbc9d7e24765e753bb0940b939e4df.png\" data-width=\"1460\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 Frontend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430 backend \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u04413. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u043e\u0435 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">npx create-react-app app<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"java\">import React, {useCallback} from 'react'; import {getSignedUrlApi, uploadToS3Api} from '..\/utils\/api';  export const Upload = ({onSetUploadImages}) => {        const onChange = useCallback(async (e) => {                let files = e.target.files                    \/\/ \u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443         const signedUrlResults = await getSignedUrlApi()         const {url, fileName} = signedUrlResults                  \/\/ \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 S3         await uploadToS3Api(url, files[0])         onSetUploadImages(fileName)            }, [onSetUploadImages])      return (         &lt;div className=\"upload\">             &lt;div>                 &lt;input type=\"file\" onChange={onChange} \/>             &lt;\/div>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/github.com\/avkos\/simple-serverless-front\" rel=\"noopener noreferrer nofollow\">\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u044d\u0442\u043e \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 Serverless Framework \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 S3 \u0441\u0430\u0439\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0443\u043f\u0435\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0430:<\/p>\n<pre><code class=\"yaml\">service: service provider:   name: aws  plugins:   - serverless-lift  constructs:   front:     type: static-website     path: 'build'<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c <code>yarn build<\/code> \u0438 <code>sls deploy<\/code>. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ff\/552\/921\/8ff55292104b01d2c9f5f0436677c0a2.gif\" data-width=\"1280\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 backend+frontend+image convertor. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/lambda\/pricing\/?loc=ft#Free_Tier\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Lambda<\/a>:<\/p>\n<p><em>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f AWS Lambda \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 1\u00a0\u043c\u043b\u043d \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u0435\u0441\u044f\u0446 \u0438 400\u00a0000\u00a0\u0413\u0411-\u0441\u0435\u043a\u0443\u043d\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u043c\u0435\u0441\u044f\u0446<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/api-gateway\/pricing\/\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Api Gateway<\/a><\/p>\n<p><em>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f API Gateway \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u043e\u0432 API HTTP, \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u043e\u0432 API REST, \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 750\u00a0000\u00a0\u043c\u0438\u043d\u0443\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0435\u0441\u044f\u0446 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0434\u043e 12\u00a0\u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/s3\/pricing\/?nc=sn&amp;loc=4\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 S3<\/a><\/p>\n<p><em>\u041d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b AWS \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 5 \u0413\u0411 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Amazon S3 \u043a\u043b\u0430\u0441\u0441\u0430 S3 Standard, 20 000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 GET, 2000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 PUT, COPY, POST, \u0438\u043b\u0438 LIST, \u0430 \u0442\u0430\u043a\u0436\u0435 100 \u0413\u0411 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430.<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/cloudfront\/pricing\/?nc=sn&amp;loc=3\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Cloudfront<\/a><\/p>\n<p><em>\u0412\u0441\u0435\u0433\u0434\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e  1 \u0422\u0411 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 10 000 000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 HTTP \u0438\u043b\u0438 HTTPS 2 000 000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 CloudFront Function<\/em><\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e (\u0447\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0435\u0439 \u0438 \u0441\u043b\u0430\u0431\u043e \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432).<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445 <a href=\"https:\/\/github.com\/avkos\/simple-serverless-front\" rel=\"noopener noreferrer nofollow\">simple-serverless-front<\/a>, <a href=\"https:\/\/github.com\/avkos\/simple-serverless-back\" rel=\"noopener noreferrer nofollow\">simple-serverless-back<\/a>, <a href=\"https:\/\/github.com\/avkos\/lambda-ffmpeg-tifig\" rel=\"noopener noreferrer nofollow\">lambda-ffmpeg-tifig<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/648847\/\"> https:\/\/habr.com\/ru\/post\/648847\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u044f \u0442\u0435\u043c\u0443 \u043d\u0430\u0440\u0435\u0437\u043a\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0433\u043e frontend \u0438 backend.\u00a0<\/p>\n<p>AWS S3 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 S3 \u0438\u0437 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u042f \u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c Frontend, Backend, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0440\u0435\u0437\u043a\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/648519\/\" rel=\"noopener noreferrer nofollow\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e<\/a>, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u043d\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 backend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a:<\/p>\n<pre><code class=\"javascript\">const {S3Client, PutObjectCommand} = require('@aws-sdk\/client-s3'); const {v4} = require(\"uuid\");  const s3 = new S3Client({     signatureVersion: 'v4',     region: config.REGION });  const S3PutObjectCommand = (Key) => {     return new PutObjectCommand({         ACL: 'public-read',         Bucket: config.S3_BUCKET,         Key,     }); } const getS3SignedUrl = (name) => {     const command = S3PutObjectCommand(name)     return getSignedUrl(s3, command, {expiresIn: 600}) } const getFileName = (key) => `${key}.jpg`;  const generateFileKey = () => {     return v4() }  module.exports.handler = async () => {     const key = generateFileKey()     const fileName = getFileName(key)     const url = await getS3SignedUrl(fileName);     return {         statusCode: 200,       \/\/ \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0434\u043b\u044f CORS.          \/\/ \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0442\u0430\u043a,          \/\/ \u0447\u0442\u043e\u0431 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432         headers: {             'Content-Type': 'application\/json',             'Access-Control-Allow-Origin': '*',             'Access-Control-Allow-Credentials': true,         },         body: JSON.stringify({key, url, fileName})     }; }<\/code><\/pre>\n<p>\u041e\u0431\u0435\u0440\u043d\u0435\u043c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 Lambda \u0438 ApiGateway \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Serverless Framework.\u00a0<\/p>\n<pre><code class=\"yaml\">service: service-simple-serverless-back frameworkVersion: '2 || 3' app: simple-serverless-back  package:   patterns:     - '!node_modules\/aws-sdk'     - '!node_modules\/serverless'     - '!node_modules\/@serverless'     - '!.idea'     - '!images'     - '!yarn.lock'     - '!yarn.error.log'     - '!README.md'     - '!.gitignore'     - '!package.json'     - '!.git'  custom:   name: 'simple-serverless-back'   environment: 'prod'   region: 'us-east-1'   # \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u043a\u0435\u0442 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b,    # \u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f   bucket: 'service-lambda-thumb-tifig-d-sourcebucketdc914398-10oo755kbh9e8'   lambda_prefix: ${self:custom.environment}-${self:custom.name}  provider:   name: aws   lambdaHashingVersion: '20201221'   environment:     S3_BUCKET: ${self:custom.bucket}     REGION: ${self:custom.region}   region: ${self:custom.region}   runtime: nodejs14.x   iamRoleStatements:     - Effect: Allow       Action:         - s3:PutObject         - s3:PutObjectAcl         - s3:GetObject       Resource:         - 'arn:aws:s3:::${self:custom.bucket}'         - 'arn:aws:s3:::${self:custom.bucket}\/*'  functions:   getS3SignedUrl:     name: get-s3-signed-url     handler: index.handler     events:       - http:           method: GET           path: \/           cors: true <\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c <code>sls deploy<\/code> \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043b\u044f\u043c\u0431\u0434\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 Frontend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0435\u0440\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043d\u0430 backend \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u04413. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u043e\u0435 React \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">npx create-react-app app<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"java\">import React, {useCallback} from 'react'; import {getSignedUrlApi, uploadToS3Api} from '..\/utils\/api';  export const Upload = ({onSetUploadImages}) => {        const onChange = useCallback(async (e) => {                let files = e.target.files                    \/\/ \u0431\u0435\u0440\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443         const signedUrlResults = await getSignedUrlApi()         const {url, fileName} = signedUrlResults                  \/\/ \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0432 S3         await uploadToS3Api(url, files[0])         onSetUploadImages(fileName)            }, [onSetUploadImages])      return (         &lt;div className=\"upload\">             &lt;div>                 &lt;input type=\"file\" onChange={onChange} \/>             &lt;\/div>         &lt;\/div>     ); } <\/code><\/pre>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d <a href=\"https:\/\/github.com\/avkos\/simple-serverless-front\" rel=\"noopener noreferrer nofollow\">\u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0435\u0440\u043d\u0435\u043c \u044d\u0442\u043e \u0432\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 Serverless Framework \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 S3 \u0441\u0430\u0439\u0442 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0443\u043f\u0435\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0430:<\/p>\n<pre><code class=\"yaml\">service: service provider:   name: aws  plugins:   - serverless-lift  constructs:   front:     type: static-website     path: 'build'<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c <code>yarn build<\/code> \u0438 <code>sls deploy<\/code>. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0435\u0441\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 backend+frontend+image convertor. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/lambda\/pricing\/?loc=ft#Free_Tier\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Lambda<\/a>:<\/p>\n<p><em>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f AWS Lambda \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 1\u00a0\u043c\u043b\u043d \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043c\u0435\u0441\u044f\u0446 \u0438 400\u00a0000\u00a0\u0413\u0411-\u0441\u0435\u043a\u0443\u043d\u0434 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0432 \u043c\u0435\u0441\u044f\u0446<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/api-gateway\/pricing\/\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Api Gateway<\/a><\/p>\n<p><em>\u0423\u0440\u043e\u0432\u0435\u043d\u044c \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f API Gateway \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u043e\u0432 API HTTP, \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u043e\u0432 API REST, \u043e\u0434\u0438\u043d \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438 750\u00a0000\u00a0\u043c\u0438\u043d\u0443\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043c\u0435\u0441\u044f\u0446 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0434\u043e 12\u00a0\u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/s3\/pricing\/?nc=sn&amp;loc=4\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 S3<\/a><\/p>\n<p><em>\u041d\u043e\u0432\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u044b AWS \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 5 \u0413\u0411 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 Amazon S3 \u043a\u043b\u0430\u0441\u0441\u0430 S3 Standard, 20 000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 GET, 2000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 PUT, COPY, POST, \u0438\u043b\u0438 LIST, \u0430 \u0442\u0430\u043a\u0436\u0435 100 \u0413\u0411 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0442\u0440\u0430\u0444\u0438\u043a\u0430.<\/em><\/p>\n<p><a href=\"https:\/\/aws.amazon.com\/ru\/cloudfront\/pricing\/?nc=sn&amp;loc=3\" rel=\"noopener noreferrer nofollow\">\u0426\u0435\u043d\u044b \u043d\u0430 Cloudfront<\/a><\/p>\n<p><em>\u0412\u0441\u0435\u0433\u0434\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e  1 \u0422\u0411 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 10 000 000 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 HTTP \u0438\u043b\u0438 HTTPS 2 000 000 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 CloudFront Function<\/em><\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0443\u043c\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e (\u0447\u0442\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0430\u0434\u043c\u0438\u043d \u043f\u0430\u043d\u0435\u043b\u0435\u0439 \u0438 \u0441\u043b\u0430\u0431\u043e \u043d\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432).<\/p>\n<p>\u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u0445 <a href=\"https:\/\/github.com\/avkos\/simple-serverless-front\" rel=\"noopener noreferrer nofollow\">simple-serverless-front<\/a>, <a href=\"https:\/\/github.com\/avkos\/simple-serverless-back\" rel=\"noopener noreferrer nofollow\">simple-serverless-back<\/a>, <a href=\"https:\/\/github.com\/avkos\/lambda-ffmpeg-tifig\" rel=\"noopener noreferrer nofollow\">lambda-ffmpeg-tifig<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/648847\/\"> https:\/\/habr.com\/ru\/post\/648847\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328886","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=328886"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328886\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}