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
| private var authToken: String? { | |
| didSet { | |
| service.invalidateConfiguration() | |
| guard let token = authToken else { return } | |
| let jwt = try? JWTDecode.decode(jwt: token) | |
| tokenExpiryDate = jwt?.expiresAt | |
| } | |
| } |
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
| if let text: String = resource.typedContent() { | |
| print(text) | |
| } |
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
| func resourceChanged(_ resource: Resource, event: ResourceEvent) { | |
| if let status: [String: String] = resource.typedContent() { | |
| print("\(status)") | |
| } | |
| } |
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
| fileprivate init() { | |
| ... | |
| let jsonDecoder = JSONDecoder() | |
| // –––––– Mapping from specific paths to models –––––– | |
| service.configureTransformer("/status") { | |
| try jsonDecoder.decode([String: String].self, from: $0.content) |
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 Siesta | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| AwesomeAPI.ping().addObserver(self) | |
| } | |
| override func viewWillAppear(_ animated: Bool) { |
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 Siesta | |
| let baseURL = "https://jwt-api-siesta.herokuapp.com" | |
| let AwesomeAPI = _AwesomeAPI() | |
| class _AwesomeAPI { | |
| // MARK: - Configuration | |
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
| node -e "console.log(require('crypto').randomBytes(32).toString('hex'));" |
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.route('/users/<string:user_id>') | |
| def users(user_id): | |
| profile = firebase.get('/users/{}'.format(user_id), "public") | |
| return jsonify(profile) | |
| @app.route('/users') | |
| def users_by_email(): | |
| # TODO: single network call | |
| email = request.args.get("email") |
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
| curl "http://api.mytravatar.com/[email protected]" | |
| { | |
| "city": "San Carlos", | |
| "country": "United States", | |
| "country_emoji": "🇺🇸", | |
| "country_short": "US" | |
| } |
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
| { | |
| "rules": { | |
| "users": { | |
| "$uid": { | |
| "location": { | |
| ".write": "$uid === auth.uid", | |
| ".read": "$uid === auth.uid" | |
| }, | |
| "twitter": { | |
| ".write": "$uid === auth.uid", |