mirror of
				https://gitcode.com/gh_mirrors/re/react-native-pushy.git
				synced 2025-10-31 21:33:12 +08:00 
			
		
		
		
	feat: project init
This commit is contained in:
		
							
								
								
									
										10
									
								
								.github/workflows/scripts/functions/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								.github/workflows/scripts/functions/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| # Compiled JavaScript files | ||||
| lib/**/*.js | ||||
| lib/**/*.js.map | ||||
|  | ||||
| # TypeScript v1 declaration files | ||||
| typings/ | ||||
|  | ||||
| # Node.js dependency directory | ||||
| node_modules/ | ||||
| yarn.lock | ||||
							
								
								
									
										24
									
								
								.github/workflows/scripts/functions/package.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.github/workflows/scripts/functions/package.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| { | ||||
|   "name": "functions", | ||||
|   "scripts": { | ||||
|     "build": "tsc", | ||||
|     "serve": "npm run build && firebase emulators:start --only functions", | ||||
|     "shell": "npm run build && firebase functions:shell", | ||||
|     "start": "npm run shell", | ||||
|     "deploy": "firebase deploy --only functions", | ||||
|     "logs": "firebase functions:log" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": "16" | ||||
|   }, | ||||
|   "main": "lib/index.js", | ||||
|   "dependencies": { | ||||
|     "firebase-admin": "^11.3.0", | ||||
|     "firebase-functions": "^4.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "firebase-functions-test": "^3.0.0", | ||||
|     "typescript": "^4.9.5" | ||||
|   }, | ||||
|   "private": true | ||||
| } | ||||
							
								
								
									
										13
									
								
								.github/workflows/scripts/functions/src/exports.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/scripts/functions/src/exports.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
| */ | ||||
|  | ||||
| /* eslint-disable global-require */ | ||||
| module.exports = { | ||||
|   SAMPLE_DATA: require('./functions/sample-data'), | ||||
| }; | ||||
							
								
								
									
										12
									
								
								.github/workflows/scripts/functions/src/index.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/scripts/functions/src/index.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| import * as functions from 'firebase-functions'; | ||||
|  | ||||
| // // Start writing Firebase Functions | ||||
| // // https://firebase.google.com/docs/functions/typescript | ||||
| // | ||||
| export const helloWorld = functions.https.onRequest((request, response) => { | ||||
|   functions.logger.info('Hello logs!', { structuredData: true }); | ||||
|   response.send('{ "data": "Hello from Firebase!" }'); | ||||
| }); | ||||
|  | ||||
| export { testFunctionCustomRegion } from './testFunctionCustomRegion'; | ||||
| export { testFunctionDefaultRegion } from './testFunctionDefaultRegion'; | ||||
							
								
								
									
										80
									
								
								.github/workflows/scripts/functions/src/sample-data.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								.github/workflows/scripts/functions/src/sample-data.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| /* | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| const SAMPLE_DATA: { [key: string]: any } = { | ||||
|   number: 1234, | ||||
|   string: 'acde', | ||||
|   boolean: true, | ||||
|   null: null, | ||||
|   object: { | ||||
|     number: 1234, | ||||
|     string: 'acde', | ||||
|     boolean: true, | ||||
|     null: null, | ||||
|   }, | ||||
|   array: [1234, 'acde', true, null], | ||||
|   deepObject: { | ||||
|     array: [1234, 'acde', false, null], | ||||
|     object: { | ||||
|       number: 1234, | ||||
|       string: 'acde', | ||||
|       boolean: true, | ||||
|       null: null, | ||||
|       array: [1234, 'acde', true, null], | ||||
|     }, | ||||
|     number: 1234, | ||||
|     string: 'acde', | ||||
|     boolean: true, | ||||
|     null: null, | ||||
|   }, | ||||
|   deepArray: [ | ||||
|     1234, | ||||
|     'acde', | ||||
|     true, | ||||
|     null, | ||||
|     [1234, 'acde', true, null], | ||||
|     { | ||||
|       number: 1234, | ||||
|       string: 'acde', | ||||
|       boolean: true, | ||||
|       null: null, | ||||
|       array: [1234, 'acde', true, null], | ||||
|     }, | ||||
|   ], | ||||
|   deepMap: { | ||||
|     number: 123, | ||||
|     string: 'foo', | ||||
|     booleanTrue: true, | ||||
|     booleanFalse: false, | ||||
|     null: null, | ||||
|     list: ['1', 2, true, false], | ||||
|     map: { | ||||
|       number: 123, | ||||
|       string: 'foo', | ||||
|       booleanTrue: true, | ||||
|       booleanFalse: false, | ||||
|       null: null, | ||||
|     }, | ||||
|   }, | ||||
|   deepList: [ | ||||
|     '1', | ||||
|     2, | ||||
|     true, | ||||
|     false, | ||||
|     ['1', 2, true, false], | ||||
|     { | ||||
|       number: 123, | ||||
|       string: 'foo', | ||||
|       booleanTrue: true, | ||||
|       booleanFalse: false, | ||||
|       null: null, | ||||
|     }, | ||||
|   ], | ||||
| }; | ||||
|  | ||||
| export default SAMPLE_DATA; | ||||
							
								
								
									
										14
									
								
								.github/workflows/scripts/functions/src/testFunctionCustomRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								.github/workflows/scripts/functions/src/testFunctionCustomRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| import * as functions from 'firebase-functions'; | ||||
|  | ||||
| export const testFunctionCustomRegion = functions | ||||
|   .region('europe-west1') | ||||
|   .https.onCall(() => 'europe-west1'); | ||||
							
								
								
									
										70
									
								
								.github/workflows/scripts/functions/src/testFunctionDefaultRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								.github/workflows/scripts/functions/src/testFunctionDefaultRegion.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| /* | ||||
|  * | ||||
|  *  Testing tools for invertase/react-native-firebase use only. | ||||
|  * | ||||
|  *  Copyright (C) 2018-present Invertase Limited <oss@invertase.io> | ||||
|  * | ||||
|  *  See License file for more information. | ||||
|  */ | ||||
|  | ||||
| import * as assert from 'assert'; | ||||
| import { FirebaseError } from 'firebase-admin'; | ||||
| import * as functions from 'firebase-functions'; | ||||
| import SAMPLE_DATA from './sample-data'; | ||||
|  | ||||
| export const testFunctionDefaultRegion = functions.https.onCall(data => { | ||||
|   console.log(Date.now(), data); | ||||
|  | ||||
|   if (typeof data === 'undefined') { | ||||
|     return 'undefined'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'string') { | ||||
|     return 'string'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'number') { | ||||
|     return 'number'; | ||||
|   } | ||||
|  | ||||
|   if (typeof data === 'boolean') { | ||||
|     return 'boolean'; | ||||
|   } | ||||
|  | ||||
|   if (data === null) { | ||||
|     return 'null'; | ||||
|   } | ||||
|  | ||||
|   if (Array.isArray(data)) { | ||||
|     return 'array'; | ||||
|   } | ||||
|  | ||||
|   const { type, asError, inputData } = data; | ||||
|   if (!Object.hasOwnProperty.call(SAMPLE_DATA, type)) { | ||||
|     throw new functions.https.HttpsError('invalid-argument', 'Invalid test requested.'); | ||||
|   } | ||||
|  | ||||
|   const outputData = SAMPLE_DATA[type]; | ||||
|  | ||||
|   try { | ||||
|     assert.deepEqual(outputData, inputData); | ||||
|   } catch (e) { | ||||
|     console.error(e); | ||||
|     throw new functions.https.HttpsError( | ||||
|       'invalid-argument', | ||||
|       'Input and Output types did not match.', | ||||
|       (e as FirebaseError).message, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   // all good | ||||
|   if (asError) { | ||||
|     throw new functions.https.HttpsError( | ||||
|       'cancelled', | ||||
|       'Response data was requested to be sent as part of an Error payload, so here we are!', | ||||
|       outputData, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   return outputData; | ||||
| }); | ||||
							
								
								
									
										16
									
								
								.github/workflows/scripts/functions/tsconfig.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								.github/workflows/scripts/functions/tsconfig.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| { | ||||
|   "compilerOptions": { | ||||
|     "module": "commonjs", | ||||
|     "noImplicitReturns": true, | ||||
|     "noUnusedLocals": true, | ||||
|     "outDir": "lib", | ||||
|     "sourceMap": true, | ||||
|     "skipLibCheck": true, | ||||
|     "strict": true, | ||||
|     "target": "es2017" | ||||
|   }, | ||||
|   "compileOnSave": true, | ||||
|   "include": [ | ||||
|     "src" | ||||
|   ] | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 steven
					steven