This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Those imports are to react-native-firebase and firebase storage. | |
| If you use other client stuff, you must to replace the imports | |
| by the include/imports of your languange | |
| or framework, as well as the respective calls. | |
| */ | |
| // START ---- | |
| import firebase from '@react-native-firebase/app' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Views.js | |
| ````` | |
| import React from 'react' | |
| import { NavigationContainer } from '@react-navigation/native' | |
| import { createNativeStackNavigator } from '@react-navigation/native-stack' | |
| const Stack = createNativeStackNavigator(); | |
| const options = (route,params) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { AsyncStorage } from 'react-native' | |
| import Location from './Location.js' | |
| class Backend { | |
| static get = async (url,params,callback) => { | |
| let p = '' | |
| params = (params ? params : {}) | |
| const {location, status} = await Location.getAsync(); | |
| if(!location)return; | |
| let endpoint = null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Platform, PermissionsAndroid } from 'react-native' | |
| import { Constants, Permissions } from 'react-native-unimodules' | |
| import NetInfo from "@react-native-community/netinfo"; | |
| import * as L from 'expo-location' | |
| class Location { | |
| static getAsync = async () => { | |
| if (Platform.OS === 'android' && !Constants.isDevice) { | |
| throw new Exception('Geolocation only in devices not emulators.') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App::Api.controllers do | |
| before do | |
| auth_user | |
| end | |
| get '/me' | |
| {id:@user[:id],name:@user[:name],username:@user[:username]}.to_json | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App::Api.controllers do | |
| before do | |
| auth_user | |
| end | |
| get '/list/friends' | |
| {friends:['Joao','Maria','May']}.to_json | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sha256 = Digest::SHA256.hexdigest "some key goes here you should generate yours" | |
| HMAC_SECRET = sha256 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uricache = URI.parse(ENV["REDIS_URL"]) | |
| CACHE = Redis.new(:host => uricache.host, :port => uricache.port, :password => uricache.password) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def auth_user user=nil | |
| #token = JWT.decode(params[:token], hmac_secret, true, { :algorithm => 'HS256' }) | |
| token = request.env["HTTP_TOKEN"] | |
| halt 401, "token + user are nil" if (token.blank? && user.blank?) | |
| @user ||= CACHE.get(token) | |
| unless @user.blank? | |
| halt 400, "existent user for a blank token" if token.blank? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import Date from require('./components/Date.js') | |
| export default class App extends Component { | |
| initAsync = async (that) => { | |
| } | |
| constructor(props) { | |
| super(props) |