Skip to content

Commit

Permalink
feat: export validatte mod via validation.ts to prevent conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorikairox committed Oct 7, 2022
1 parent b11afe6 commit f546352
Show file tree
Hide file tree
Showing 19 changed files with 247 additions and 157 deletions.
21 changes: 17 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
## Description

<!-- Include a summary of the change made and also list the dependencies that are required if any -->

---

## Issue Ticket Number

Fixes #(issue_number)

---

## Type of change

<!-- Please select all options that are applicable. -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Breaking change (fix or feature that would cause existing functionality to
not work as expected)
- [ ] This change requires a documentation update

---

# Checklist:
- [ ] I have run `deno lint` AND `deno fmt` AND `deno task test` and got no errors.
- [ ] I have followed the contributing guidelines of this project as mentioned in [CONTRIBUTING.md](/CONTRIBUTING.md)
- [ ] I have checked to ensure there aren't other open [Pull Requests](https://github.com/Savory/Danet/pulls) for the same update/change?

- [ ] I have run `deno lint` AND `deno fmt` AND `deno task test` and got no
errors.
- [ ] I have followed the contributing guidelines of this project as mentioned
in [CONTRIBUTING.md](/CONTRIBUTING.md)
- [ ] I have checked to ensure there aren't other open
[Pull Requests](https://github.com/Savory/Danet/pulls) for the same
update/change?
- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes needed to the documentation
53 changes: 27 additions & 26 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
nationality, personal appearance, race, religion, or sexual identity and
orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
Expand All @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
- Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand All @@ -60,8 +60,8 @@ representative at an online or offline event.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
<-how-to-contact-you->.
All complaints will be reviewed and investigated promptly and fairly.
<-how-to-contact-you->. All complaints will be reviewed and investigated
promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Expand All @@ -82,15 +82,15 @@ behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series
of actions.
**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

Expand All @@ -106,23 +106,24 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
the community.
**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
Community Impact Guidelines were inspired by
[Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
https://www.contributor-covenant.org/translations.
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

🤟 Thanks for coming here and contributing to Danet 🤟

## How do I contribute :
## How do I contribute :

- Create an issue for bug or feature request
- Comment an existing issue to say that you are tackling it
- Join [our discord](https://discord.gg/Q7ZHuDPgjA)

## I don't know where to start

Look for issues with 'good first issue'. If there is none but you are willing to contribute, hop on discord to talk about what can be done on the project. There is always things to do !
Look for issues with 'good first issue'. If there is none but you are willing to
contribute, hop on discord to talk about what can be done on the project. There
is always things to do !

### I am new to programming/typescript, I'm afraid to make mistake

Do not worry. We all had to learn at some point. The best thing you can do it pick an issue and give it a try.
Do not worry. We all had to learn at some point. The best thing you can do it
pick an issue and give it a try.

If you feel lost or don't know what to do or how to do something, come on our discord and we will guide you. We might even do pair programming together !
If you feel lost or don't know what to do or how to do something, come on our
discord and we will guide you. We might even do pair programming together !
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ A huge thanks to
</a>
</p>

## Contributing


## Contributing

- Contributions make the open source community such an amazing place to learn, inspire, and create.
- Contributions make the open source community such an amazing place to learn,
inspire, and create.
- Any contributions you make are **truly appreciated**.
- Check out our [contribution guidelines](/CONTRIBUTING.md) for more information.

- Check out our [contribution guidelines](/CONTRIBUTING.md) for more
information.

<h2>
License
Expand Down
18 changes: 12 additions & 6 deletions spec/auth-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ for (const guardType of ['controller', 'method']) {
const app = new DanetApplication();
await app.init(ControllerGuardModule);
const listenEvent = await app.listen(0);
const res = await fetch(`http://localhost:${listenEvent.port}/${guardType}-guard`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/${guardType}-guard`,
{
method: 'GET',
},
);
const json = await res.json();
assertEquals(json, {
[`passedIn${guardType}Guard`]: true,
Expand Down Expand Up @@ -132,9 +135,12 @@ Deno.test('403 when guard is throwing', async () => {
const app = new DanetApplication();
await app.init(ThrowingAuthModule);
const listenEvent = await app.listen(0);
const res = await fetch(`http://localhost:${listenEvent.port}/throwing-guard`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/throwing-guard`,
{
method: 'GET',
},
);
const errorStatus = res.status;
assertEquals(errorStatus, 403);
const json = await res.json();
Expand Down
9 changes: 6 additions & 3 deletions spec/exception-filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ for (
await app.init(ModuleWithFilter);
const listenEvent = await app.listen(0);

const res = await fetch(`http://localhost:${listenEvent.port}/custom-error`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/custom-error`,
{
method: 'GET',
},
);
const json = await res.json();
assertEquals(json, {
wePassedInFilterCatchingOnlySomeError: true,
Expand Down
9 changes: 6 additions & 3 deletions spec/http-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ for (const method of ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']) {
await app.init(MyModule);
const listenEvent = await app.listen(0);

const res = await fetch(`http://localhost:${listenEvent.port}/nice-controller`, {
method,
});
const res = await fetch(
`http://localhost:${listenEvent.port}/nice-controller`,
{
method,
},
);
const text = await res.text();
assertEquals(text, `OK ${method}`);
await app.close();
Expand Down
25 changes: 16 additions & 9 deletions spec/method-param-decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class SimpleController {
}

@Get('/query/all')
simpleGetAll(@Query({ value: 'array' }) queryParams: Record<string, string[]>) {
simpleGetAll(
@Query({ value: 'array' }) queryParams: Record<string, string[]>,
) {
return queryParams;
}

Expand All @@ -37,7 +39,9 @@ class SimpleController {
}

@Get('/query/first')
simpleGetFirst(@Query({ value: 'first' }) queryParams: Record<string, string>) {
simpleGetFirst(
@Query({ value: 'first' }) queryParams: Record<string, string>,
) {
return queryParams;
}

Expand Down Expand Up @@ -80,9 +84,12 @@ Deno.test('@Res and @Query decorator', async () => {
await app.init(MyModule);
const listenEvent = await app.listen(0);

const res = await fetch(`http://localhost:${listenEvent.port}/query/myvalue/all?myvalue=foo`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/query/myvalue/all?myvalue=foo`,
{
method: 'GET',
},
);
const text = await res.text();
assertEquals(text, `["foo"]`);

Expand All @@ -100,7 +107,7 @@ Deno.test(`@Query decorator with value 'array' to return all values for a given
},
);
const json = await res.json();
assertEquals(json, ['foo','bar']);
assertEquals(json, ['foo', 'bar']);

await app.close();
});
Expand Down Expand Up @@ -148,7 +155,7 @@ Deno.test(`@Query decorator with no key and value 'array' to return all values o
},
);
const json = await res.json();
assertEquals(json, {myvalue: ['foo','bar']});
assertEquals(json, { myvalue: ['foo', 'bar'] });

await app.close();
});
Expand All @@ -164,7 +171,7 @@ Deno.test(`@Query decorator with no key and value 'last' to return the last valu
},
);
const json = await res.json();
assertEquals(json, {myvalue: 'bar'});
assertEquals(json, { myvalue: 'bar' });

await app.close();
});
Expand All @@ -180,7 +187,7 @@ Deno.test(`@Query decorator with no key and value 'first' to return the first va
},
);
const json = await res.json();
assertEquals(json, {myvalue: 'foo'});
assertEquals(json, { myvalue: 'foo' });

await app.close();
});
Expand Down
9 changes: 6 additions & 3 deletions spec/scoped-lifecycle-hook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ Deno.test('Scoped Lifecycle hooks', async (testContext) => {
async () => {
const listenEvent = await app.listen(0);

const res = await fetch(`http://localhost:${listenEvent.port}/scoped-controller/`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/scoped-controller/`,
{
method: 'GET',
},
);
const text = await res.text();
assertEquals(text, `Received a GET request`);
await app.close();
Expand Down
11 changes: 7 additions & 4 deletions spec/view-renderer.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { path, assertEquals } from '../src/deps_test.ts';
import { assertEquals, path } from '../src/deps_test.ts';
import { DanetApplication } from '../src/app.ts';
import { Module } from '../src/module/decorator.ts';
import { Render } from '../src/renderer/decorator.ts';
Expand All @@ -25,9 +25,12 @@ Deno.test('Hbs renderer', async () => {
app.setViewEngineDir(viewPath);
const listenEvent = await app.listen(0);

const res = await fetch(`http://localhost:${listenEvent.port}/nice-controller`, {
method: 'GET',
});
const res = await fetch(
`http://localhost:${listenEvent.port}/nice-controller`,
{
method: 'GET',
},
);
const text = await res.text();
assertEquals(text.includes('my title'), true);
await app.close();
Expand Down
2 changes: 1 addition & 1 deletion src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
Response,
Router,
} from 'https://deno.land/x/[email protected]/mod.ts';
export type { State, Route } from 'https://deno.land/x/[email protected]/mod.ts';
export type { Route, State } from 'https://deno.land/x/[email protected]/mod.ts';
export { getQuery } from 'https://deno.land/x/[email protected]/helpers.ts';
export {
green,
Expand Down
Loading

0 comments on commit f546352

Please sign in to comment.