temba 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -179,13 +179,13 @@ If you want to do input validation before the `POST` or `PUT` request body is sa
179
179
  ```js
180
180
  const config = {
181
181
  requestBodyValidator: {
182
- post: (resourceName, requestBody) {
182
+ post: (resourceName, requestBody) => {
183
183
  // Validate, or even change the requestBody
184
184
  },
185
- put: (resourceName, requestBody) {
185
+ put: (resourceName, requestBody) => {
186
186
  // Validate, or even change the requestBody
187
- }
188
- }
187
+ },
188
+ },
189
189
  }
190
190
 
191
191
  const server = temba.create(config)
@@ -206,16 +206,21 @@ Example:
206
206
  ```js
207
207
  const config = {
208
208
  requestBodyValidator: {
209
- post: (resourceName, requestBody) {
209
+ post: (resourceName, requestBody) => {
210
210
  // Do not allow Pokemons to be created: 400 Bad Request
211
- if (resourceName === 'pokemons') return 'You are not allowed to create new Pokemons'
211
+ if (resourceName === 'pokemons')
212
+ return 'You are not allowed to create new Pokemons'
212
213
 
213
214
  // Add a genre to Star Trek films:
214
- if (resourceName === 'movies' && requestBody.title.startsWith('Star Trek')) return {...requestBody, genre: 'Science Fiction'}
215
+ if (
216
+ resourceName === 'movies' &&
217
+ requestBody.title.startsWith('Star Trek')
218
+ )
219
+ return { ...requestBody, genre: 'Science Fiction' }
215
220
 
216
221
  // If you end up here, void will be returned, so the request will just be saved.
217
222
  },
218
- }
223
+ },
219
224
  }
220
225
 
221
226
  const server = temba.create(config)
@@ -236,13 +241,13 @@ const config = {
236
241
  cacheControl: 'public, max-age=300',
237
242
  delay: 500,
238
243
  requestBodyValidator: {
239
- post: (resourceName, requestBody) {
244
+ post: (resourceName, requestBody) => {
240
245
  // Validate, or even change the requestBody
241
246
  },
242
- put: (resourceName, requestBody) {
247
+ put: (resourceName, requestBody) => {
243
248
  // Validate, or even change the requestBody
244
- }
245
- }
249
+ },
250
+ },
246
251
  }
247
252
  const server = temba.create(config)
248
253
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temba",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Get a simple MongoDB REST API with zero coding in less than 30 seconds (seriously).",
5
5
  "main": "dist/server.js",
6
6
  "scripts": {