-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from michielbdejong/1200156-custom-id-schemas
Fixes #138 - Implement custom id schema's
- Loading branch information
Showing
11 changed files
with
408 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
/** | ||
* Id schema class, providing an interface for generating and validating | ||
* id's. | ||
* | ||
* This class is provided as a base class you should extend to implement your | ||
* own id schemas. | ||
*/ | ||
export default class IdSchema { | ||
get type() { | ||
return "idschema"; | ||
} | ||
|
||
generate() { | ||
throw new Error("Not implemented."); | ||
} | ||
|
||
validate(id) { | ||
throw new Error("Not implemented."); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
import IdSchema from "./idschema"; | ||
|
||
import { v4 as uuid4 } from "uuid"; | ||
import { isUUID4 } from "../utils"; | ||
|
||
/** | ||
* The UUID4-based IdSchema used by default for Kinto collections. | ||
*/ | ||
export default class UUIDSchema extends IdSchema { | ||
generate() { | ||
return uuid4(); | ||
} | ||
|
||
validate(id) { | ||
return isUUID4(id); | ||
} | ||
} |
Oops, something went wrong.