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
... | |
pipeline :api do | |
plug :accepts, ["json"] | |
plug Guardian.Plug.Pipeline, module: GuardianSimpleAuth.Guardian, error_handler: GuardianSimpleAuth.ErrorHandler | |
plug Guardian.Plug.VerifySession, claims: %{"typ" => "access"} | |
plug Guardian.Plug.VerifyHeader, claims: %{"typ" => "access"} | |
plug Guardian.Plug.LoadResource, allow_blank: true | |
end | |
pipeline :auth do |
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
brew update | |
brew install elixir | |
mix local.hex | |
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez | |
//install node.js版本(建議8.0之後) | |
//install postgres版本(建議至少9.4之後) | |
取得dev.secret.exs | |
設定資料庫 mix ecto.setup |
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
defmodule Dresser.Worker do | |
@moduledoc "The store, based on `Agent`." | |
def start_link do | |
result = Agent.start_link(fn -> %{} end, name: __MODULE__) | |
__MODULE__.put(:free_dress, 3) | |
result | |
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
alias Bootleg.{UI, Config} | |
use Bootleg.DSL | |
# Configure the following roles to match your environment. | |
# `build` defines what remote server your distillery release should be built on. | |
# | |
# Some available options are: | |
# - `user`: ssh username to use for SSH authentication to the role's hosts | |
# - `password`: password to be used for SSH authentication | |
# - `identity`: local path to an identity file that will be used for SSH authentication instead of a 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
FROM ubuntu:16.04 | |
# Avoid error messages from apt during image build | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN \ | |
apt-get update && \ | |
apt-get install -y wget curl gnupg |
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
//-----types.graphql | |
type Post { | |
id: Int | |
user_id: Int | |
title: String | |
description: String | |
created_at: Date | |
updated_at: Date | |
} |
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
//當你需要依照作者列出個人所有的文章時: | |
query Users{ | |
users { | |
id | |
username | |
posts { | |
title | |
description | |
} | |
} |
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
const DataLoader = require('dataloader') | |
/** | |
* Creates a dataloader for a supplied model. | |
* | |
* @param {String} model e.g. 'App/Models/User' | |
* @param {String} ref_id e.g. 'order_id' | |
* @returns {DataLoader} | |
*/ | |
function createLoader(model, ref_id = 'id', has = 'one') { |
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
const createLoader = require('../Helpers/loaders/createLoader') | |
/** | |
* Define your loaders here. | |
* Each key should be a valid | |
* instance of DataLoader. | |
*/ | |
const loaders = () => ({ | |
user_group: createLoader('App/Models/UserGroup'), | |
user_personal_data: createLoader('App/Models/PersonalData', 'user_id'), |
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/data/resolvers.js | |
const resolvers = { | |
Query: { | |
... | |
async users() { | |
const users = await User.all() | |
return users.toJSON() | |
}, | |
... |