@@ -116,6 +116,8 @@ Ongoing development is, in part, funded by both [Stripe](https://stripe.com) and
116116
1171171 . [ Introduction] ( #introduction )
1181181 . [ Why FunctionScript?] ( #why-functionscript )
119+ 1 . [ FunctionScript Examples] ( #functionscript-examples )
120+ 1 . [ All Available Types] ( #all-available-types )
1191211 . [ Specification] ( #specification )
120122 1 . [ FunctionScript Resource Definition] ( #functionscript-resource-definition )
121123 1 . [ Context Definition] ( #context-definition )
@@ -243,6 +245,54 @@ additional tooling:
243245- Type-Safety Mechanisms at the HTTP -> Code Interface
244246- Automatically Generated API Documentation
245247
248+ # FunctionScript Examples
249+
250+ We'll be updating this section with examples for you to play with and modify
251+ on your own.
252+
253+ ## All Available Types
254+
255+ Here's an example of a hypothetical ` createUser.js ` function that can be used
256+ to create a user resource. It includes all available type definitions.
257+
258+ ``` javascript
259+ /**
260+ * @param {integer} id ID of the User
261+ * @param {string} username Name of the user
262+ * @param {number} age Age of the user
263+ * @param {float} communityScore Community score (between 0.00 and 100.00)
264+ * @param {object} metadata Key-value pairs corresponding to additional user data
265+ * @ {string} createdAt Created at ISO-8601 String. Required as part of metadata.
266+ * @ {?string} notes Additional notes. Nullable (not required) as part of object
267+ * @param {array} friendIds List of friend ids
268+ * @ {integer} friendId ID of a user (forces array to have all integer entries)
269+ * @param {buffer} profilePhoto Base64-encoded filedata, read into Node as a Buffer
270+ * @param {enum} userGroup The user group. Can be "USER" (read as 0) or "ADMIN" (read as 9)
271+ * ["USER", 0]
272+ * ["ADMIN", 9]
273+ * @param {boolean} overwrite Overwrite current user data, if username matching
274+ * @returns {object.http} successPage API Returns an HTTP object (webpage)
275+ */
276+ module .exports = async (id = null , username , age , communityScore , metadata , friendsIds = [], profilePhoto , userGroup , overwrite = false ) => {
277+
278+ // NOTE: id, friendIds and overwrite will be OPTIONAL as they have each been
279+ // provided a defaultValue
280+
281+ // Implementation-specific code here
282+
283+ // API Output
284+ // NOTE: Note that because "object.http" was specified, this MUST follow the
285+ // object.http schema: headers, statusCode, body
286+
287+ return {
288+ headers: {' Content-Type' : ' text/html' },
289+ statusCode: 200 ,
290+ body: Buffer .from (' Here is a success message!' )
291+ };
292+
293+ };
294+ ```
295+
246296# Specification
247297
248298## FunctionScript Resource Definition
0 commit comments