Skip to content

Commit

Permalink
Merge pull request #9 from jagaapple/release/v1.0.2
Browse files Browse the repository at this point in the history
#  Changes and Fixes
- Update development environment #7
- Fix handling falsy values in checking parameters #8
  • Loading branch information
jagaapple authored Dec 6, 2019
2 parents a0e3ae6 + 96f0c0f commit 06f3125
Show file tree
Hide file tree
Showing 16 changed files with 4,449 additions and 1,211 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ npm-debug.log
lib

# Generated files created by tests.
.nyc_output
coverage
15 changes: 0 additions & 15 deletions .nycrc.json

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ semi: true
# Use single quotes instead of double quotes.
singleQuote: false

# Change when properties in objects are quoted.
quoteProps: "as-needed"

# Use single quotes instead of double quotes in JSX.
# jsxSingleQuote: false

# Print trailing commas wherever possible when multi-line (A single-line array, for example, never gets trailing commas).
trailingComma: "all"

Expand Down
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// ---------------------------------------------------------------------------------------------------------------------------
// Editor
// ---------------------------------------------------------------------------------------------------------------------------
// Insert snippets when their prefix matches.
// Inserts snippets when their prefix matches.
// Works best when 'quickSuggestions' aren't enabled.
"editor.tabCompletion": "on",
// Columns at which to show vertical rulers.
Expand All @@ -14,12 +14,12 @@
// ---------------------------------------------------------------------------------------------------------------------------
// Files
// ---------------------------------------------------------------------------------------------------------------------------
// Configure glob patterns for excluding files and folders.
// Configures glob patterns for excluding files and folders.
"files.exclude": {
"**/node_modules/**": true
"**/node_modules": true
},

// Configure glob patterns of file paths to exclude from file watching.
// Configures glob patterns of file paths to exclude from file watching.
// Changing this setting requires a restart. When you experience Code consuming
// lots of cpu time on startup, you can exclude large folders to reduce the initial load.
"files.watcherExclude": {
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Changelog
## 1.0.2 (2019-12-07)
- Fix parameters and query parameteres checking when giving falsy values such as zero #8 - [@jagaapple](https://github.com/jagaapple)
- Update development environment #7 - [@jagaapple](https://github.com/jagaapple)

## 1.0.1 (2019-10-09)
- Fix `createRoute` function parse #5 - [@jagaapple](https://github.com/jagaapple)


## 1.0.0 (2019-10-09)
- Initial public release - [@jagaapple](https://github.com/jagaapple)


## 0.0.1 (2019-10-02)
- Initial private release - [@jagaapple](https://github.com/jagaapple)
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,16 @@ import { routes } from "../routes.ts";

const targetUserId = 5;

export default () => (
const Page () => (
<Link {...routes.usersDetail(targetUserId)}>
<a>Go to the user page (id: {targetUserId})</a>
</Link>
);

// And it is possible to redirect URL for unviersal (client and server-side)!
import Router from "next/router";
import { createPageMover } from "next-typed-routes";

const movePage = createPageMover("https://you-project.example.com", Router);

...
Component.getInitialProps = async ({ res }) => {
Page.getInitialProps = async ({ res }) => {
// Redirect to `/users/123&limit=30` .
// This works fine on web browsers and server-side.
// This works fine on client-side and server-side.
movePage(routes.usersDetail(123), { res, queryParameters: { limit: 30 } })
};
```
Expand Down Expand Up @@ -78,12 +72,12 @@ Component.getInitialProps = async ({ res }) => {

## Features

| FEATURES | WHAT YOU CAN DO |
|------------------------------------|-----------------------------------------------------------------|
| ❤️ **Designed for Next.js** | You can use Next.js built-in routing system |
| 🌐 **Build for Universal** | Ready for Universal JavaScript |
| 📄 **Write once, Manage one file** | All you need is write routes to one file |
| 🎩 **Type Safe** | You can get errors when missing required dynamic URL parameters |
| FEATURES | WHAT YOU CAN DO |
|------------------------------------|----------------------------------------------------------|
| ❤️ **Designed for Next.js** | You can use Next.js routing system without custom server |
| 🌐 **Build for Universal** | Ready for Universal JavaScript |
| 📄 **Write once, Manage one file** | All you need is write routes to one file |
| 🎩 **Type Safe** | You can use with TypeScript |

### Motivation
Next.js 9 is the first version to support dynamic routing without any middleware. It is so useful and easy to use, and it supports
Expand All @@ -99,17 +93,17 @@ you can create links type safely.

## Quick Start
### Requirements
- Node.js 10.0.0 or higher
- npm or Yarn
- **Next.js 9 or higher**
- Node.js 10.0.0 or higher
- **Next.js 9.0.0 or higher**


### Installation
```bash
$ npm install --save-dev next-typed-routes
$ npm install next-typed-routes
```

If you use Yarn, use the following command.
If you are using Yarn, use the following command.

```bash
$ yarn add --dev next-typed-routes
Expand All @@ -132,11 +126,11 @@ export const routes = {
};
```

First, you need to define routes using next-typed-routes.
Firstly, you need to define routes using next-typed-routes.

`createRoute` function exported from next-typed-routes returns an object for `<Link>` component props, which has `href` and `as`
properties.
So when you manage values created by `createRoute` by keys, you can get `<Link>` component props via the keys like the following.
So when you manage values created by `createRoute`, you can get `<Link>` component props via the keys like the following.

```tsx
<Link {...routes.top}>
Expand Down
190 changes: 190 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// Respect "browser" field in package.json when resolving modules
// browser: false,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/88/kfhvhbw51qlgmj4jxjpb34vw0000gn/T/jest_dx",

// Automatically clear mock calls and instances between every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: null,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: [
"html",
// "json",
"text",
"lcov",
// "clover"
],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: null,

// A path to a custom dependency extractor
// dependencyExtractor: null,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],

// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: "ts-jest",

// Run tests from one or more projects
// projects: null,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: null,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: null,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ["jest-plugin-context/setup"],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)",
"**/src/**/?(*.)+(spec|test).[tj]s?(x)",
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: null,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: null,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: null,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
Loading

0 comments on commit 06f3125

Please sign in to comment.