0.8.0 • Published 16 days ago

@amilochau/core-vue3 v0.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
16 days ago

@amilochau/core-vue3 is a opinionated package used to create vue.js v3 applications.

Main features

  • Application layout, with header and footer bars, navigation drawer, snackbar for messages
  • Privacy with cookies approbation via a dedicated layer, privacy page, data cleaning on logout
  • API integration, with error codes handling
  • Default pages for error codes
  • Reactive SEO tags per page
  • Internationalization, light/dark themes
  • Forms validation helpers
  • Identity integration with AWS Cognito, using amilochau/core-vue3-auth
  • PWA native support, with update button

Usage

amilochau/core-vue3 is proposed as a vue plugin.

  1. Install the npm packages

Run the following command to install the npm package:

npm install @amilochau/core-vue3 @amilochau/core-vue3-auth

Note that amilochau/core-vue3-auth is optional - you can skip it if you don't need authentication with AWS Cognito.

  1. Configure the plugin

Define your coreOptions - use a dedicated file for better code separation:

import type { MilochauCoreOptions } from "@amilochau/core-vue3"

export const coreOptions: MilochauCoreOptions = {
  application: {
    name: 'YOU APPLICATION NAME',
    contact: 'YOUR APPLICATION OWNER',
    navigation: {
      items: ref([
        // YOUR APPLICATION NAVIGATION LINKS
      ])
    },
    isProduction: true,
  },
  api: {
    gatewayUri: 'YOUR API BASE URI'
  },
  i18: {
    messages: {
      en: {}, // <== USE THIS SECTION TO ADD GLOBAL ENGLISH TRANSLATIONS
      fr: {}  // <== USE THIS SECTION TO ADD GLOBAL FRENCH TRANSLATIONS
    },
  },
  identity: {
    cognito: {
      userPoolId: 'YOUR COGNITO USER POOL ID',
      clientId: 'YOUR COGNITO CLIENT ID',
    }
  },
  routes: [], // <== USE THIS SECTION TO ADD ROUTES
  clean: () => () => {} // WHAT TO CALL TO CLEAN LOCAL DATA ON LOGOUT
}
  1. Register the plugin

Register amilochau/core-vue3 in your main file:

import { createCoreVue3App } from '@amilochau/core-vue3'
import { coreOptions } from './data/config'

import 'vuetify/styles'

export const coreVue3App = await createCoreVue3App(App, coreOptions);

If you want to use authentication, register amilochau/core-vue3-auth in your main file:

import { createCoreVue3AuthApp } from '@amilochau/core-vue3-auth'
import { coreOptions } from './data/config'

import 'vuetify/styles'

export const coreVue3App = await createCoreVue3AuthApp(coreOptions);

Dependencies

The following plugins are installed by @amilochau/core-vue3:

  • pinia
  • vue-i18n
  • vue-router
  • vuetify
  • vite-plugin-pwa

The following plugin is installed by @amilochau/core-vue3-auth:

  • aws-amplify

See the full list of dependencies here.

Composition API

Here are the helpers you can use from your code.

HelperDescription
useApiAnonymousSends HTTP requests to the API gateway configured via api.gatewayUri ; manages HTTP errors
useApiSends authenticated HTTP requests to the API gateway configured via api.gatewayUri ; manages HTTP errors (only if amilochau/core-vue3-auth is configured)
useCleanCleans data from storage, typically on logout, as configured via clean
useCognitoInteract with AWS Cognito (only if amilochau/core-vue3-auth is configured)
useCoreOptionsLets you get the core options defined on plugin registration
useHandleHandle asynchronous requests to manage errors, with loader bar and snackbar messages
useNavigationHelps you use router with back navigation
useNotificationsLets you register your application for push notifications
usePageDefine page metadata
useValidationRulesLets you use pre-defined validation rules on plain data

Here are the pinia stores you can use from your code.

Store nameHelperDescription
appuseAppStoreLets you display messages in a snackbar
cookiesuseCookiesStoreLets you known if the current user has accepted cookies
identityuseIdentityStoreLets you display data from the current user
languageuseLanguageStoreLets you know the current language configured for the UI
notificationsuseNotificationsStoreLets you get data on notifications registration
themeuseThemeStoreLets you know the current theme configured for the UI
pwausePwaStoreLets you manage the PWA application updates

Options

Here are the options you should provide in the MilochauCoreOptions class.

Configuration pathDescription
application.nameName of the application
application.contactApplication owner, as used in the policy page
application.logoUrlURL of the application logo
application.navigation.itemsNavigation links, as vuetify list items, used in the navigation drawer
application.isProductionWhether the current application is production
api.gatewayUriBase URI used by the useApi composition API
i18nOptions used by vue-i18n
identity.cognitoCognito settings for authentication
routesList of vue-router routes, to register application pages
cleanFunction called on logout, typically used to delete personal data from pinia stores
pwa.hideInstallBtnHide the PWA install button from the header bar
notifications.pushKeyPublic VAPID key for push notifications
notifications.registerFunction called on notifications registration, typically used to call an API to save the registration data

See the full definition of options here.

You can find a sample of these configuration options in the sample app options.

Notes

  • You have to define a route named Home, so that default redirections can work.

Contribute

Feel free to push your code if you agree with publishing under the MIT license.

0.8.0

16 days ago

0.8.0-beta.34

17 days ago

0.8.0-beta.35

17 days ago

0.8.0-beta.33

18 days ago

0.8.0-beta.32

2 months ago

0.8.0-beta.31

3 months ago

0.8.0-beta.29

3 months ago

0.8.0-beta.30

3 months ago

0.8.0-beta.27

3 months ago

0.8.0-beta.28

3 months ago

0.8.0-beta.26

4 months ago

0.8.0-beta.25

5 months ago

0.8.0-beta.24

5 months ago

0.8.0-beta.23

5 months ago

0.8.0-beta.19

6 months ago

0.8.0-beta.21

5 months ago

0.8.0-beta.22

5 months ago

0.8.0-beta.20

6 months ago

0.8.0-beta.18

6 months ago

0.8.0-beta.14

6 months ago

0.8.0-beta.15

6 months ago

0.8.0-beta.16

6 months ago

0.8.0-beta.17

6 months ago

0.8.0-beta.13

6 months ago

0.8.0-beta.10

7 months ago

0.8.0-beta.11

6 months ago

0.8.0-beta.12

6 months ago

0.8.0-beta.8

7 months ago

0.8.0-beta.9

7 months ago

0.7.0-beta.2

11 months ago

0.7.0-beta.3

11 months ago

0.7.0-beta.8

10 months ago

0.7.0-beta.9

10 months ago

0.7.0-beta.4

11 months ago

0.7.0-beta.5

11 months ago

0.7.0-beta.6

11 months ago

0.7.0-beta.7

11 months ago

0.7.0-beta.16

9 months ago

0.7.0-beta.15

9 months ago

0.7.0-beta.18

9 months ago

0.7.0-beta.17

9 months ago

0.7.0-beta.10

9 months ago

0.7.0-beta.12

9 months ago

0.7.0-beta.11

9 months ago

0.7.0-beta.14

9 months ago

0.7.0-beta.13

9 months ago

0.7.0

9 months ago

0.8.0-beta.5

8 months ago

0.8.0-beta.6

7 months ago

0.8.0-beta.3

8 months ago

0.8.0-beta.4

8 months ago

0.8.0-beta.1

8 months ago

0.8.0-beta.2

8 months ago

0.7.0-beta.1

11 months ago

0.6.2

11 months ago

0.6.1

11 months ago

0.5.7

12 months ago

0.5.6-beta.1

1 year ago

0.5.6-beta.2

1 year ago

0.5.6-beta.3

1 year ago

0.5.4

1 year ago

0.5.6

1 year ago

0.6.0

12 months ago

0.5.0-beta.1

1 year ago

0.5.0-beta.7

1 year ago

0.5.0-beta.6

1 year ago

0.5.0-beta.5

1 year ago

0.5.0-beta.4

1 year ago

0.5.0-beta.3

1 year ago

0.5.0-beta.2

1 year ago

0.5.3

1 year ago

0.5.0

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.4.0

1 year ago

0.4.0-beta.3

1 year ago

0.4.0-beta.2

1 year ago

0.4.0-beta.1

1 year ago

0.3.3-beta.2

1 year ago

0.3.3-beta.1

1 year ago

0.3.2

1 year ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.1.0-beta.6

2 years ago

0.1.0-beta.5

2 years ago

0.1.0-beta.4

2 years ago

0.1.0-beta.3

2 years ago

0.1.0-beta.2

2 years ago

0.1.0-beta.1

2 years ago