{"version":3,"file":"server.mjs","sources":["../../../src/apis/server.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { getAmplifyServerContext, } from '@aws-amplify/core/internals/adapter-core';\nimport { del as commonDel, get as commonGet, head as commonHead, patch as commonPatch, post as commonPost, put as commonPut, } from './common/publicApis';\n/**\n * GET HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {GetInput} input - Input for GET operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a GET request\n * ```js\n * import { get } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { body } = await get(contextSpec, input).response;\n *       return await body.json();\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const get = (contextSpec, input) => commonGet(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * POST HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PostInput} input - Input for POST operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a POST request\n * ```js\n * import { post } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { body } = await post(contextSpec, input).response;\n *       return await body.json();\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const post = (contextSpec, input) => commonPost(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PUT HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PutInput} input - Input for PUT operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PUT request\n * ```js\n * import { put } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { body } = await put(contextSpec, input).response;\n *       return await body.json();\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const put = (contextSpec, input) => commonPut(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * DELETE HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {DeleteInput} input - Input for DELETE operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a DELETE request\n * ```js\n * import { del } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { headers } = await del(contextSpec, input).response;\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const del = (contextSpec, input) => commonDel(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * HEAD HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {HeadInput} input - Input for HEAD operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a HEAD request\n * ```js\n * import { head } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { headers } = await head(contextSpec, input).response;\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const head = (contextSpec, input) => commonHead(getAmplifyServerContext(contextSpec).amplify, input);\n/**\n * PATCH HTTP request (server-side)\n * @param {AmplifyServer.ContextSpec} contextSpec - The context spec used to get the Amplify server context.\n * @param {PatchInput} input - Input for PATCH operation.\n * @throws - {@link RestApiError}\n * @example\n * Send a PATCH request\n * ```js\n * import { patch } from 'aws-amplify/api/server';\n * //...\n * const restApiResponse = await runWithAmplifyServerContext({\n *   nextServerContext: { request, response },\n *   operation: async (contextSpec) => {\n *     try {\n *       const { body } = await patch(contextSpec, input).response;\n *       return await body.json();\n *     } catch (error) {\n *       console.log(error);\n *       return false;\n *     }\n *   },\n * });\n * ```\n */\nexport const patch = (contextSpec, input) => commonPatch(getAmplifyServerContext(contextSpec).amplify, input);\n"],"names":["commonGet","commonPost","commonPut","commonDel","commonHead","commonPatch"],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKA,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,GAAG,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,KAAS,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AACxG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,MAAU,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;AAC1G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,KAAK,GAAG,CAAC,WAAW,EAAE,KAAK,KAAKC,OAAW,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,KAAK;;;;"}