Skip to content

Commit

Permalink
Merge pull request #1 from social-native/feat/init
Browse files Browse the repository at this point in the history
Feat/init
  • Loading branch information
erhathaway authored Sep 24, 2019
2 parents b8f05a0 + e62e85b commit 8547d7f
Show file tree
Hide file tree
Showing 19 changed files with 8,733 additions and 0 deletions.
207 changes: 207 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
defaults: &defaults
working_directory: ~/code

save-cache: &save-cache
save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

restore-cache: &restore-cache
restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
npm-config: &npm-config
run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

version: 2.1
jobs:
test:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- *save-cache
- run: npm run test

build-verification:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- run: npm run build

type-check:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- *save-cache
- run: npm run type-check

lint-check:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- *save-cache
- run: npm run lint

beauty-check:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- *save-cache
- run: npm run prettier -- --check

dependency-check:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- *save-cache
- run: npm run dep-check
- store_artifacts:
path: /tmp/dependency-check-output.json

package-version-validation:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- run: npm install
- run: npm run package-version-validation
tag-version-validation:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- run: npm install
- run: npm run tag-version-validation
build-for-publishing:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- *restore-cache
- run: npm install
- run:
name: Build package
command: npm run build
- persist_to_workspace:
root: ~/code
paths:
- dist
publish-github-release-to-npm:
<<: *defaults
docker:
- image: circleci/node:10.16.3-stretch
steps:
- *npm-config
- checkout
- attach_workspace:
at: ~/code
- *restore-cache
- run:
name: Publish package
command: npm publish

workflows:
version: 2
test-build-deploy:
jobs:
- test:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/

- build-verification:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/

- type-check:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/

- lint-check:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/

- beauty-check:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/

- dependency-check:
filters:
tags: # run for every branch
only: /^[0-9]+(\.[0-9]+)*$/
snpkg-publish:
jobs:
- package-version-validation:
filters:
branches: # run for every branch
ignore:
- master
tags:
ignore: /.*/
- tag-version-validation:
filters:
branches:
ignore: /.*/
tags:
only: /^v{0,1}\d+\.\d+\.\d+$/
- build-for-publishing:
requires:
- tag-version-validation
filters:
branches:
ignore: /.*/
tags:
only: /^v{0,1}\d+\.\d+\.\d+$/
- publish-github-release-to-npm:
requires:
- build-for-publishing
filters:
branches:
ignore: /.*/
tags:
only: /^v{0,1}\d+\.\d+\.\d+$/
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @erhathaway
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

.rpt2_cache
tmp

dist
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"printWidth": 100
}
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858,
"restart": true,
"timeout": 10000
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"tslint.run": "onType"
}
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,66 @@
# snpkg-graphql-scalar-unix-time-sec

A GraphQL scalar for representing unix time seconds

# Install

```typescript
npm i -D @social-native/snpkg-graphql-scalar-unix-time-sec
```

# Usage

1. Import

```typescript
import unixTimeSec from '../src/index';
```

2. Use the scalar in the gql schema file

```typescript
const typeDefs = gql`
type User {
createdAt: ${unixTimeSec.type.name}
input: ${unixTimeSec.type.name}
}
type Query {
user(input: ${unixTimeSec.type.name}): User
}
`;
```

or

```graphql
type User {
createdAt: UnixTimeSec
input: UnixTimeSec
}

type Query {
user(input: UnixTimeSec): User
}
```

3. Add the resolver

```typescript
const resolvers = {
...unixTimeSec.resolver,
Query: {
async user(_, input: any) {
return {...returnValues.user, ...input};
}
}
};
```

# API

This scalar will:

- Accept inputs in either `string` or `number` format
- Validate that the input type has 10 digits (aka is between the years ~1974 to ~2463)
- Will coerce milliseconds to seconds if being sent from the server to client
Loading

0 comments on commit 8547d7f

Please sign in to comment.