Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
feat(exports): redefine exports
Browse files Browse the repository at this point in the history
  • Loading branch information
nahtnam committed Apr 20, 2019
1 parent 94e153d commit a809723
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion server/js/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { route } = require('../../../lib/index'); // eslint-disable-line
const route = require('../../../lib/index'); // eslint-disable-line

module.exports = route({
path: '/',
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/dev.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const start = Date.now();
import light from '../../index';
import { server } from '../../index';
import { CommandBuilder } from 'yargs'; // eslint-disable-line
import { join, relative } from 'path';
import emojic from 'emojic';
import { yellow, blueBright } from 'colorette';
import { yellow } from 'colorette';

import importRoute from '../../utils/import-route';
import log from '../log';
Expand Down Expand Up @@ -34,7 +34,7 @@ const handle = async (argv: Args) => {
const cwd = process.cwd();
const routesPath = join(cwd, './routes');

const app = light({
const app = server({
routes: routesPath,
log: argv.log,
});
Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export { default as Light, default as light } from './light';
export { default as route } from './route';
export { default } from './light';
const route = require('./route'); // eslint-disable-line

module.exports = route.default;
exports = route.default;

export { default as server } from './server';
export { default, default as route } from './route';
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'path';
import listen from 'test-listen';
import { resolve } from 'url';
import fetch from 'node-fetch';
import light from '../src/index';
import { server } from '../src/index';

const app = light({
const app = server({
routes: join(__dirname, 'seeds/routes'),
log: false,
});
Expand Down
4 changes: 2 additions & 2 deletions tests/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'path';
import listen from 'test-listen';
import { resolve } from 'url';
import fetch from 'node-fetch';
import light from '../src/index';
import { server } from '../src/index';

const app = light({
const app = server({
routes: join(__dirname, 'seeds/routes'),
});
let url: string;
Expand Down
4 changes: 2 additions & 2 deletions tests/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'path';
import listen from 'test-listen';
import { resolve } from 'url';
import fetch from 'node-fetch';
import light from '../src/index';
import { server } from '../src/index';

const app = light({
const app = server({
routes: join(__dirname, 'seeds/routes'),
log: false,
});
Expand Down
4 changes: 2 additions & 2 deletions tests/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'path';
import listen from 'test-listen';
import { resolve } from 'url';
import fetch from 'node-fetch';
import light from '../src/index';
import { server } from '../src/index';

const app = light({
const app = server({
routes: join(__dirname, 'seeds/routes'),
log: false,
});
Expand Down
8 changes: 4 additions & 4 deletions tests/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { join } from 'path';
import listen from 'test-listen';
import { resolve } from 'url';
import fetch from 'node-fetch';
import light from '../src/index';
import { server } from '../src/index';

describe('routes', () => {
it('should not run with errors', async () => {
expect.assertions(1);
expect(() => {
const app = light({
const app = server({
routes: join(__dirname, 'seeds/errors/routes.ts'),
log: false,
});
Expand All @@ -17,7 +17,7 @@ describe('routes', () => {
});

it('should work without slash', async () => {
const app = light({
const app = server({
routes: join(__dirname, 'seeds/routes/no-slash.ts'),
log: false,
});
Expand All @@ -30,7 +30,7 @@ describe('routes', () => {
});

it('should run with an array of routes', async () => {
const app = light({
const app = server({
routes: [join(__dirname, 'seeds/routes/function.ts'), join(__dirname, 'seeds/routes/object.ts')],
log: false,
});
Expand Down

0 comments on commit a809723

Please sign in to comment.